// ============================================================
// I18N — bilingual UI (English / Dutch). window.CJI18n + useLang.
// Code/comments stay English; only user-facing copy is translated.
// t(key, vars) falls back to English, then to the key itself, so a
// missing string can never render blank.
// ============================================================

const CJ_STRINGS = {
  en: {
    // --- common ---
    'common.login': 'Log in',
    'common.getStarted': 'Get started',
    'common.openDashboard': 'Open dashboard',
    'common.logTrade': 'Log trade',
    'common.cancel': 'Cancel',
    'common.back': 'Back',
    'common.continue': 'Continue',
    'common.save': 'Save',
    'common.close': 'Close',
    'common.delete': 'Delete',
    'common.logout': 'Log out',
    'common.trade': 'trade',
    'common.trades': 'trades',
    'common.loading': 'Loading your desk…',

    // --- landing nav + hero ---
    'land.tag': 'Built for ES & NQ confluence traders',
    'land.titlePre': 'The trading journal that ',
    'land.titleEm': 'stays out of your way.',
    'land.sub': 'Log a trade in about thirty seconds. See which confluences actually make you money. And know, at a glance, whether you stuck to your own rules. That’s it.',
    'land.ctaStart': 'Start now',
    'land.ctaHave': 'I already have an account',
    'land.note': 'Free to use · access is invite-only',

    // --- landing principle ---
    'land.principleKicker': 'The idea',
    'land.principleH2pre': 'Everything you need. ',
    'land.principleH2b': 'Nothing you don’t.',
    'land.principleP': 'Most journals make you pick between doing everything and staying simple. This one doesn’t bother with that trade-off: one job per screen, one screen per job. You’re never stuck making a choice you didn’t ask for.',

    // --- landing features ---
    'land.featKicker': 'What you get',
    'land.featTitle': 'One job, done well: knowing if your edge is real.',
    'land.feat1h': 'Log a trade in thirty seconds',
    'land.feat1p': 'Pick the instrument, drop a screenshot, tap the confluences, add a note if you feel like it. Three screens, no fuss.',
    'land.feat2h': 'A P&L calendar that doesn’t lie',
    'land.feat2p': 'Every session is a green or red day, with weekly totals down the side. Tap any day to walk back through its trades.',
    'land.feat3h': 'See which confluences actually pay',
    'land.feat3p': 'Win rate by number of confluences, your best combinations, and how often you lean on each one — so you know what your edge really is.',
    'land.feat4h': 'A discipline score, not a lecture',
    'land.feat4p': 'One number: how often you respected your own threshold. Watch the equity curve go red the moment you stop.',

    // --- landing how it works ---
    'land.howKicker': 'How it works',
    'land.howTitle': 'Three taps from a fill to a logged trade.',
    'land.s1n': 'STEP 01', 'land.s1h': 'Set it up once',
    'land.s1p': 'Choose your instrument, your sessions, and the confluences you trade. A minute, and you’re done.',
    'land.s2n': 'STEP 02', 'land.s2h': 'Log as you go',
    'land.s2p': 'Drop a screenshot, tap the confluences that lined up, set your P&L. Below your threshold? You’ll see it — it never stops you.',
    'land.s3n': 'STEP 03', 'land.s3h': 'Read your edge',
    'land.s3p': 'The calendar shows the money, the analysis shows the why. Share your best combination in one tap.',

    // --- landing cta + footer ---
    'land.ctaKicker': 'Ready?',
    'land.ctaH2': 'Stop guessing what works.',
    'land.ctaP': 'Log your next trade in thirty seconds and let the numbers settle it.',
    'land.footRight': 'For traders who keep their own score.',

    // --- mini calendar ---
    'mini.month': 'June 2026 · Net P&L',

    // --- auth ---
    'auth.asideQuote': 'A journal for ES/NQ traders who work with confluences — log in thirty seconds, see what actually works.',
    'auth.asideBy': '— Your score, kept honest.',
    'auth.titleReg': 'Create your account',
    'auth.titleLogin': 'Welcome back',
    'auth.subReg': 'You’ll be logging trades within the minute.',
    'auth.subLogin': 'Log back in to your desk.',
    'auth.google': 'Continue with Google',
    'auth.divider': 'OR WITH EMAIL',
    'auth.email': 'Email',
    'auth.password': 'Password',
    'auth.choosePw': 'Choose a password (min. 6 characters)',
    'auth.yourPw': 'Your password',
    'auth.agree': 'I agree to the terms',
    'auth.remember': 'Remember me',
    'auth.forgot': 'Forgot password?',
    'auth.createBtn': 'Create account',
    'auth.loginBtn': 'Log in',
    'auth.working': 'One moment…',
    'auth.haveAccount': 'Already have an account?',
    'auth.newHere': 'New here?',
    'auth.toLogin': 'Log in',
    'auth.toRegister': 'Create one',
    'auth.backHome': 'Back to home',
    'auth.errEnter': 'Enter your email and password.',
    'auth.infoConfirm': 'Account created. Check your inbox to confirm, then log in.',

    // --- locked ---
    'lock.kicker': 'Confluence Score',
    'lock.title': 'Members only',
    'lock.body': 'You’re signed in as {email}. Access is handed out per person — ask the owner to add you, then refresh this page.',
    'lock.refresh': 'I’ve been added — refresh',

    // --- rail / nav ---
    'rail.workspace': 'Workspace',
    'rail.today': 'Today',
    'rail.noToday': 'No trades yet today',
    'rail.member': 'MEMBER · FULL ACCESS',
    'nav.trades': 'Trades', 'nav.tradesHint': 'Calendar & list',
    'nav.analyse': 'Analyse', 'nav.analyseHint': 'Edge & discipline',
    'nav.settings': 'Settings', 'nav.settingsHint': 'Confluences & rules',
    'nav.theme': 'Theme',
    'theme.light': 'LIGHT', 'theme.dark': 'DARK',

    // --- page headers ---
    'head.calendar': 'Calendar', 'head.calendarSub': 'Your P&L, day by day.',
    'head.tradelog': 'Trade log', 'head.tradelogSub': 'Every trade, newest first.',
    'head.analyse': 'Analyse', 'head.analyseSub': 'Is your edge actually working?',
    'head.settings': 'Settings', 'head.settingsSub': 'Kept deliberately small.',
    'toggle.calendar': 'Calendar', 'toggle.list': 'List',
    'head.shareEdge': 'Share my edge',

    // --- stats (shared) ---
    'stat.winRate': 'Win rate',
    'stat.profitFactor': 'Profit factor',
    'stat.avgTrade': 'Avg / trade',
    'stat.discipline': 'Discipline',
    'stat.greenDays': 'Green days',
    'stat.bestDay': 'Best day',
    'stat.worstDay': 'Worst day',
    'stat.trades': 'Trades',
    'stat.record': 'Record',
    'stat.withinRules': 'Within rules',

    // --- calendar / list ---
    'cal.netAll': 'Net P&L · all trades',
    'cal.tradesWinners': '{n} trades · {w} winners',
    'cal.netMonth': '{month} {year} · net P&L',
    'cal.daysTraded': '{d} {dayWord} · {n} trades',
    'cal.tradingDay': 'trading day', 'cal.tradingDays': 'trading days',
    'cal.thisMonth': 'This month',
    'cal.week': 'Week',
    'cal.weekN': 'Week {n}',
    'cal.today': 'TODAY',
    'cal.profitable': 'profitable day',
    'cal.losing': 'losing day',
    'cal.clickDay': 'Tap any day to see its trades',
    'cal.tradeLog': 'Trade log',
    'cal.logSub': '{n} trades · {s} sessions',
    'list.trades': 'Trades',
    'list.thisSession': '{n} this session',
    'day.back': 'Back to calendar',
    'row.noConf': 'no confluences',
    'row.below': 'below {n}',

    // --- analyse ---
    'an.disc': 'Discipline score', 'an.discHint': 'Did you follow your own rules?',
    'an.byCount': 'Win rate by confluence count', 'an.byCountHint': 'Is your threshold right?',
    'an.combos': 'Best combinations', 'an.combosHint': 'Top 3 by win rate · min 3 trades',
    'an.freq': 'Confluence frequency', 'an.freqHint': 'What do you lean on?',
    'an.equity': 'Equity × discipline', 'an.equityHint': 'Green = threshold met',
    'an.empty': 'No data yet', 'an.emptyP': 'Log a few trades to see your edge take shape.',
    'an.followed': 'FOLLOWED',
    'an.verdictGood': 'Disciplined', 'an.verdictMid': 'Slipping', 'an.verdictBad': 'Off the rails',
    'an.ringBody': '{v}% of trades had at least your threshold of {t} confluences.',
    'an.thrNote': 'your threshold. More confluences should mean a higher win rate.',
    'an.noCombo': 'No combination with 3+ trades yet. Keep logging.',
    'an.metShort': 'met', 'an.belowShort': 'below',
    'an.shareTitle': 'Share your edge',
    'an.shareP': 'One clean card — best combo, win rate, discipline. Drop it in your Discord.',
    'an.shareBtn': 'Generate card',
    'an.trades': 'trades',

    // --- settings ---
    'set.myConf': 'My confluences',
    'set.myConfHint': '{n} active · reorder, rename, remove',
    'set.usedTimes': '{n}× used',
    'set.addConf': 'Add a confluence…',
    'set.add': 'Add',
    'set.rules': 'Rules',
    'set.minConf': 'Minimum confluences to take a trade',
    'set.looser': 'looser', 'set.balanced': 'balanced', 'set.strict': 'strict',
    'set.sessions': 'Sessions you trade',
    'set.account': 'Account',
    'set.email': 'Email',
    'set.access': 'Access',
    'set.accessDesc': 'Invite-only · all features unlocked for members.',
    'set.member': 'MEMBER',
    'set.export': 'Export data',
    'set.exportDesc': 'All trades as CSV, including confluences & notes.',
    'set.exportBtn': 'Export CSV',
    'set.exportAlert': 'CSV export — {n} trades',
    'set.instrument': 'Instrument',
    'set.rerun': 'Re-run setup',
    'set.rerunDesc': 'Walk through the short setup again.',
    'set.rerunBtn': 'Run setup',
    'set.logout': 'Log out',
    'set.logoutDesc': 'Sign out and head back to the homepage.',

    // --- log trade ---
    'log.newTrade': 'New trade · {n} / 3',
    'log.setup': 'Setup', 'log.confluences': 'Confluences', 'log.note': 'Note',
    'log.instrument': 'Instrument',
    'log.direction': 'Direction',
    'log.long': 'Long', 'log.short': 'Short',
    'log.realized': 'Realized P&L',
    'log.screenshot': 'Screenshot',
    'log.dropHint': 'Drag & drop or click to upload',
    'log.chartShot': 'chart screenshot',
    'log.remove': 'Remove',
    'log.selected': 'Selected',
    'log.belowThr': 'below your threshold of {n}',
    'log.tapToggle': 'Tap to toggle. Being below threshold never blocks you — it’s just there, logged with the trade.',
    'log.why': 'Why did you take this trade?',
    'log.optional': '— optional',
    'log.notePh': 'The idea, the trigger, what you saw…',
    'log.preview': 'Ticket preview',
    'log.confCount': '{n} confluences',
    'log.met': 'met', 'log.belowWord': 'below',
    'log.saveTrade': 'Save trade',

    // --- trade detail ---
    'det.ticket': 'Trade ticket',
    'det.confluences': 'Confluences',
    'det.below': 'BELOW', 'det.metFlag': 'MET',
    'det.none': 'None tagged.',
    'det.note': 'Note',

    // --- onboarding ---
    'onb.setup': 'CONFLUENCE SCORE · SETUP',
    'onb.counter': '{n} / 4 · ~60s',
    'onb.s0k': 'Instrument', 'onb.s0q': 'What do you trade?', 'onb.s0s': 'Pick the contract you live in.',
    'onb.s1k': 'Sessions', 'onb.s1q': 'When do you trade?', 'onb.s1s': 'Select all that apply.',
    'onb.s2k': 'Confluences', 'onb.s2q': 'What lines up your trades?', 'onb.s2s': 'Pick what fits, add what’s missing.',
    'onb.s3k': 'Threshold', 'onb.s3q': 'How many confluences, minimum?', 'onb.s3s': 'The line under which you flag a trade.',
    'onb.bothLabel': 'ES + NQ',
    'onb.addOwn': '+ Add your own…',
    'onb.selected': '{n} selected. You can change these any time in Settings.',
    'onb.enter': 'Enter the desk',

    // --- share card ---
    'sc.myEdge': 'MY EDGE',
    'sc.bestCombo': 'BEST COMBINATION → WIN RATE',
    'sc.across': 'across {n} trades',
    'sc.notEnough': 'Not enough trades yet.',
    'sc.savePng': 'Save PNG',
    'sc.copyShare': 'Copy & share',
    'sc.savedAlert': 'Saved card as PNG',
    'sc.copyText': 'My edge — Confluence Score',

    // --- months / weekdays ---
    'months': 'January,February,March,April,May,June,July,August,September,October,November,December',
    'dow': 'Mon,Tue,Wed,Thu,Fri,Sat,Sun',
    'date.today': 'Today', 'date.yesterday': 'Yesterday',
    // session labels (ids from CJData.SESSIONS)
    'sess.pre': 'Pre-market', 'sess.open': 'NY Open', 'sess.mid': 'Midday', 'sess.pm': 'NY Afternoon',
    // aria
    'aria.prevMonth': 'Previous month', 'aria.nextMonth': 'Next month', 'aria.toggleTheme': 'Toggle theme',
    // forgot / reset password
    'auth.resetSent': 'Password reset link sent. Check your inbox.',
    'auth.resetNeedEmail': 'Enter your email first, then tap “Forgot password?”.',
    'reset.title': 'Set a new password',
    'reset.sub': 'Choose a new password for your account.',
    'reset.new': 'New password',
    'reset.placeholder': 'New password (min. 6 characters)',
    'reset.save': 'Save password',
    'reset.done': 'Password updated. Taking you to your desk…',
    // screenshot upload
    'log.uploading': 'Uploading…',
    'log.removeShot': 'Remove',
    'log.addShot': 'Add screenshot',
    'det.noShot': 'No screenshot',
  },

  nl: {
    // --- common ---
    'common.login': 'Inloggen',
    'common.getStarted': 'Beginnen',
    'common.openDashboard': 'Naar dashboard',
    'common.logTrade': 'Trade loggen',
    'common.cancel': 'Annuleren',
    'common.back': 'Terug',
    'common.continue': 'Verder',
    'common.save': 'Opslaan',
    'common.close': 'Sluiten',
    'common.delete': 'Verwijderen',
    'common.logout': 'Uitloggen',
    'common.trade': 'trade',
    'common.trades': 'trades',
    'common.loading': 'Je desk laden…',

    // --- landing ---
    'land.tag': 'Gemaakt voor ES- & NQ-confluence-traders',
    'land.titlePre': 'De trading journal die ',
    'land.titleEm': 'je niet in de weg zit.',
    'land.sub': 'Log een trade in een seconde of dertig. Zie welke confluences je echt geld opleveren. En weet in één oogopslag of je je eigen regels volgde. Meer niet.',
    'land.ctaStart': 'Nu beginnen',
    'land.ctaHave': 'Ik heb al een account',
    'land.note': 'Gratis te gebruiken · toegang op uitnodiging',

    'land.principleKicker': 'Het idee',
    'land.principleH2pre': 'Alles wat je nodig hebt. ',
    'land.principleH2b': 'Niets wat je niet nodig hebt.',
    'land.principleP': 'De meeste journals laten je kiezen tussen alles kunnen en simpel blijven. Deze doet niet aan die afweging: één taak per scherm, één scherm per taak. Je zit nooit vast aan een keuze waar je niet om vroeg.',

    'land.featKicker': 'Wat je krijgt',
    'land.featTitle': 'Eén taak, goed gedaan: weten of je edge echt is.',
    'land.feat1h': 'Een trade in dertig seconden',
    'land.feat1p': 'Kies het instrument, plak een screenshot, tik je confluences aan, voeg een notitie toe als je zin hebt. Drie schermen, geen gedoe.',
    'land.feat2h': 'Een P&L-kalender die niet liegt',
    'land.feat2p': 'Elke sessie een groene of rode dag, met weektotalen aan de zijkant. Tik op een dag om z’n trades terug te zien.',
    'land.feat3h': 'Zie welke confluences echt lonen',
    'land.feat3p': 'Winrate per aantal confluences, je beste combinaties, en hoe vaak je op elk leunt — zodat je weet wat je edge echt is.',
    'land.feat4h': 'Een discipline-score, geen preek',
    'land.feat4p': 'Één getal: hoe vaak je je eigen grens respecteerde. Zie de equity-curve rood worden zodra je stopt.',

    'land.howKicker': 'Hoe het werkt',
    'land.howTitle': 'Drie tikken van fill tot gelogde trade.',
    'land.s1n': 'STAP 01', 'land.s1h': 'Eén keer instellen',
    'land.s1p': 'Kies je instrument, je sessies en de confluences die je handelt. Een minuut en je bent klaar.',
    'land.s2n': 'STAP 02', 'land.s2h': 'Log terwijl je handelt',
    'land.s2p': 'Plak een screenshot, tik de confluences aan die klopten, zet je P&L. Onder je grens? Je ziet het — het houdt je nooit tegen.',
    'land.s3n': 'STAP 03', 'land.s3h': 'Lees je edge',
    'land.s3p': 'De kalender toont het geld, de analyse het waarom. Deel je beste combinatie met één tik.',

    'land.ctaKicker': 'Klaar?',
    'land.ctaH2': 'Stop met gokken wat werkt.',
    'land.ctaP': 'Log je volgende trade in dertig seconden en laat de cijfers het beslissen.',
    'land.footRight': 'Voor traders die hun eigen score bijhouden.',

    'mini.month': 'Juni 2026 · Netto P&L',

    // --- auth ---
    'auth.asideQuote': 'Een journal voor ES/NQ-traders die met confluences werken — log in dertig seconden, zie wat echt werkt.',
    'auth.asideBy': '— Je score, eerlijk bijgehouden.',
    'auth.titleReg': 'Maak je account',
    'auth.titleLogin': 'Welkom terug',
    'auth.subReg': 'Binnen een minuut log je je eerste trade.',
    'auth.subLogin': 'Log weer in op je desk.',
    'auth.google': 'Doorgaan met Google',
    'auth.divider': 'OF MET E-MAIL',
    'auth.email': 'E-mail',
    'auth.password': 'Wachtwoord',
    'auth.choosePw': 'Kies een wachtwoord (min. 6 tekens)',
    'auth.yourPw': 'Je wachtwoord',
    'auth.agree': 'Ik ga akkoord met de voorwaarden',
    'auth.remember': 'Onthoud mij',
    'auth.forgot': 'Wachtwoord vergeten?',
    'auth.createBtn': 'Account aanmaken',
    'auth.loginBtn': 'Inloggen',
    'auth.working': 'Momentje…',
    'auth.haveAccount': 'Heb je al een account?',
    'auth.newHere': 'Nieuw hier?',
    'auth.toLogin': 'Inloggen',
    'auth.toRegister': 'Maak er een aan',
    'auth.backHome': 'Terug naar home',
    'auth.errEnter': 'Vul je e-mail en wachtwoord in.',
    'auth.infoConfirm': 'Account aangemaakt. Check je inbox om te bevestigen, en log dan in.',

    // --- locked ---
    'lock.kicker': 'Confluence Score',
    'lock.title': 'Alleen voor leden',
    'lock.body': 'Je bent ingelogd als {email}. Toegang gaat per persoon — vraag de eigenaar om je toe te voegen en ververs daarna deze pagina.',
    'lock.refresh': 'Ik ben toegevoegd — ververs',

    // --- rail / nav ---
    'rail.workspace': 'Werkruimte',
    'rail.today': 'Vandaag',
    'rail.noToday': 'Nog geen trades vandaag',
    'rail.member': 'LID · VOLLEDIGE TOEGANG',
    'nav.trades': 'Trades', 'nav.tradesHint': 'Kalender & lijst',
    'nav.analyse': 'Analyse', 'nav.analyseHint': 'Edge & discipline',
    'nav.settings': 'Instellingen', 'nav.settingsHint': 'Confluences & regels',
    'nav.theme': 'Thema',
    'theme.light': 'LICHT', 'theme.dark': 'DONKER',

    // --- page headers ---
    'head.calendar': 'Kalender', 'head.calendarSub': 'Je P&L, dag voor dag.',
    'head.tradelog': 'Trade-log', 'head.tradelogSub': 'Elke trade, nieuwste eerst.',
    'head.analyse': 'Analyse', 'head.analyseSub': 'Werkt je edge echt?',
    'head.settings': 'Instellingen', 'head.settingsSub': 'Bewust klein gehouden.',
    'toggle.calendar': 'Kalender', 'toggle.list': 'Lijst',
    'head.shareEdge': 'Deel mijn edge',

    // --- stats ---
    'stat.winRate': 'Winrate',
    'stat.profitFactor': 'Profitfactor',
    'stat.avgTrade': 'Gem. / trade',
    'stat.discipline': 'Discipline',
    'stat.greenDays': 'Groene dagen',
    'stat.bestDay': 'Beste dag',
    'stat.worstDay': 'Slechtste dag',
    'stat.trades': 'Trades',
    'stat.record': 'Resultaat',
    'stat.withinRules': 'Binnen regels',

    // --- calendar / list ---
    'cal.netAll': 'Netto P&L · alle trades',
    'cal.tradesWinners': '{n} trades · {w} winnaars',
    'cal.netMonth': '{month} {year} · netto P&L',
    'cal.daysTraded': '{d} {dayWord} · {n} trades',
    'cal.tradingDay': 'handelsdag', 'cal.tradingDays': 'handelsdagen',
    'cal.thisMonth': 'Deze maand',
    'cal.week': 'Week',
    'cal.weekN': 'Week {n}',
    'cal.today': 'VANDAAG',
    'cal.profitable': 'winstgevende dag',
    'cal.losing': 'verliesdag',
    'cal.clickDay': 'Tik op een dag voor de trades',
    'cal.tradeLog': 'Trade-log',
    'cal.logSub': '{n} trades · {s} sessies',
    'list.trades': 'Trades',
    'list.thisSession': '{n} deze sessie',
    'day.back': 'Terug naar kalender',
    'row.noConf': 'geen confluences',
    'row.below': 'onder {n}',

    // --- analyse ---
    'an.disc': 'Discipline-score', 'an.discHint': 'Volgde je je eigen regels?',
    'an.byCount': 'Winrate per aantal confluences', 'an.byCountHint': 'Klopt je grens?',
    'an.combos': 'Beste combinaties', 'an.combosHint': 'Top 3 op winrate · min. 3 trades',
    'an.freq': 'Confluence-frequentie', 'an.freqHint': 'Waar leun je op?',
    'an.equity': 'Equity × discipline', 'an.equityHint': 'Groen = grens gehaald',
    'an.empty': 'Nog geen data', 'an.emptyP': 'Log een paar trades om je edge te zien ontstaan.',
    'an.followed': 'GEVOLGD',
    'an.verdictGood': 'Gedisciplineerd', 'an.verdictMid': 'Het glipt weg', 'an.verdictBad': 'Het spoor bijster',
    'an.ringBody': '{v}% van je trades had minstens je grens van {t} confluences.',
    'an.thrNote': 'jouw grens. Meer confluences zou een hogere winrate moeten geven.',
    'an.noCombo': 'Nog geen combinatie met 3+ trades. Blijf loggen.',
    'an.metShort': 'gehaald', 'an.belowShort': 'eronder',
    'an.shareTitle': 'Deel je edge',
    'an.shareP': 'Eén strakke kaart — beste combo, winrate, discipline. Gooi ’m in je Discord.',
    'an.shareBtn': 'Kaart maken',
    'an.trades': 'trades',

    // --- settings ---
    'set.myConf': 'Mijn confluences',
    'set.myConfHint': '{n} actief · herorden, hernoem, verwijder',
    'set.usedTimes': '{n}× gebruikt',
    'set.addConf': 'Confluence toevoegen…',
    'set.add': 'Toevoegen',
    'set.rules': 'Regels',
    'set.minConf': 'Minimaal aantal confluences voor een trade',
    'set.looser': 'losser', 'set.balanced': 'gebalanceerd', 'set.strict': 'streng',
    'set.sessions': 'Sessies die je handelt',
    'set.account': 'Account',
    'set.email': 'E-mail',
    'set.access': 'Toegang',
    'set.accessDesc': 'Op uitnodiging · alle functies vrij voor leden.',
    'set.member': 'LID',
    'set.export': 'Data exporteren',
    'set.exportDesc': 'Alle trades als CSV, inclusief confluences & notities.',
    'set.exportBtn': 'CSV exporteren',
    'set.exportAlert': 'CSV-export — {n} trades',
    'set.instrument': 'Instrument',
    'set.rerun': 'Setup opnieuw',
    'set.rerunDesc': 'Loop de korte setup nog eens door.',
    'set.rerunBtn': 'Setup starten',
    'set.logout': 'Uitloggen',
    'set.logoutDesc': 'Log uit en ga terug naar de homepage.',

    // --- log trade ---
    'log.newTrade': 'Nieuwe trade · {n} / 3',
    'log.setup': 'Setup', 'log.confluences': 'Confluences', 'log.note': 'Notitie',
    'log.instrument': 'Instrument',
    'log.direction': 'Richting',
    'log.long': 'Long', 'log.short': 'Short',
    'log.realized': 'Gerealiseerde P&L',
    'log.screenshot': 'Screenshot',
    'log.dropHint': 'Sleep of klik om te uploaden',
    'log.chartShot': 'chart-screenshot',
    'log.remove': 'Verwijderen',
    'log.selected': 'Geselecteerd',
    'log.belowThr': 'onder je grens van {n}',
    'log.tapToggle': 'Tik om te wisselen. Onder je grens zitten blokkeert je nooit — het staat er gewoon, gelogd bij de trade.',
    'log.why': 'Waarom nam je deze trade?',
    'log.optional': '— optioneel',
    'log.notePh': 'Het idee, de trigger, wat je zag…',
    'log.preview': 'Ticket-voorbeeld',
    'log.confCount': '{n} confluences',
    'log.met': 'gehaald', 'log.belowWord': 'eronder',
    'log.saveTrade': 'Trade opslaan',

    // --- trade detail ---
    'det.ticket': 'Trade-ticket',
    'det.confluences': 'Confluences',
    'det.below': 'ERONDER', 'det.metFlag': 'GEHAALD',
    'det.none': 'Niets getagd.',
    'det.note': 'Notitie',

    // --- onboarding ---
    'onb.setup': 'CONFLUENCE SCORE · SETUP',
    'onb.counter': '{n} / 4 · ~60s',
    'onb.s0k': 'Instrument', 'onb.s0q': 'Wat handel je?', 'onb.s0s': 'Kies het contract waar je in leeft.',
    'onb.s1k': 'Sessies', 'onb.s1q': 'Wanneer handel je?', 'onb.s1s': 'Selecteer alles wat past.',
    'onb.s2k': 'Confluences', 'onb.s2q': 'Wat lijnt je trades op?', 'onb.s2s': 'Kies wat past, voeg toe wat mist.',
    'onb.s3k': 'Grens', 'onb.s3q': 'Hoeveel confluences minimaal?', 'onb.s3s': 'De grens waaronder je een trade markeert.',
    'onb.bothLabel': 'ES + NQ',
    'onb.addOwn': '+ Voeg je eigen toe…',
    'onb.selected': '{n} geselecteerd. Je kunt dit altijd aanpassen in Instellingen.',
    'onb.enter': 'Naar de desk',

    // --- share card ---
    'sc.myEdge': 'MIJN EDGE',
    'sc.bestCombo': 'BESTE COMBINATIE → WINRATE',
    'sc.across': 'over {n} trades',
    'sc.notEnough': 'Nog niet genoeg trades.',
    'sc.savePng': 'PNG opslaan',
    'sc.copyShare': 'Kopiëren & delen',
    'sc.savedAlert': 'Kaart opgeslagen als PNG',
    'sc.copyText': 'Mijn edge — Confluence Score',

    // --- months / weekdays ---
    'months': 'januari,februari,maart,april,mei,juni,juli,augustus,september,oktober,november,december',
    'dow': 'ma,di,wo,do,vr,za,zo',
    'date.today': 'Vandaag', 'date.yesterday': 'Gisteren',
    // session labels
    'sess.pre': 'Voorbeurs', 'sess.open': 'NY Open', 'sess.mid': 'Middag', 'sess.pm': 'NY Namiddag',
    // aria
    'aria.prevMonth': 'Vorige maand', 'aria.nextMonth': 'Volgende maand', 'aria.toggleTheme': 'Thema wisselen',
    // forgot / reset password
    'auth.resetSent': 'Reset-link verstuurd. Check je inbox.',
    'auth.resetNeedEmail': 'Vul eerst je e-mail in en tik dan op “Wachtwoord vergeten?”.',
    'reset.title': 'Nieuw wachtwoord instellen',
    'reset.sub': 'Kies een nieuw wachtwoord voor je account.',
    'reset.new': 'Nieuw wachtwoord',
    'reset.placeholder': 'Nieuw wachtwoord (min. 6 tekens)',
    'reset.save': 'Wachtwoord opslaan',
    'reset.done': 'Wachtwoord aangepast. Je gaat naar je desk…',
    // screenshot upload
    'log.uploading': 'Uploaden…',
    'log.removeShot': 'Verwijderen',
    'log.addShot': 'Screenshot toevoegen',
    'det.noShot': 'Geen screenshot',
  },
};

(function () {
  const detect = () => {
    const saved = localStorage.getItem('cj-lang');
    if (saved === 'en' || saved === 'nl') return saved;
    return (navigator.language || 'en').toLowerCase().startsWith('nl') ? 'nl' : 'en';
  };
  let _lang = detect();

  const interpolate = (s, vars) => {
    if (!vars) return s;
    return s.replace(/\{(\w+)\}/g, (m, k) => (k in vars ? vars[k] : m));
  };

  window.CJI18n = {
    get lang() { return _lang; },
    get locale() { return _lang === 'nl' ? 'nl-NL' : 'en-US'; },
    set(l) {
      if (l !== 'en' && l !== 'nl') return;
      _lang = l;
      localStorage.setItem('cj-lang', l);
      document.documentElement.setAttribute('lang', l);
      window.dispatchEvent(new Event('cj-lang'));
    },
    t(key, vars) {
      const dict = CJ_STRINGS[_lang] || CJ_STRINGS.en;
      const s = (dict[key] != null ? dict[key] : (CJ_STRINGS.en[key] != null ? CJ_STRINGS.en[key] : key));
      return interpolate(s, vars);
    },
    // localized arrays (months, weekdays)
    list(key) { return (CJ_STRINGS[_lang][key] || CJ_STRINGS.en[key] || '').split(','); },
  };
  document.documentElement.setAttribute('lang', _lang);
})();
