const TRANSLATIONS = {
  de: {
    // Document
    'doc.title': 'dentson — Der erste akustische Dentalreiniger',

    // Nav
    'nav.product': 'Produkt',
    'nav.team': 'Team',
    'nav.jobs': 'Jobs',
    'nav.waitlist': 'Warteliste',

    // Hero
    'hero.line1': 'Wir machen Zähneputzen',
    'hero.word1': 'einfacher.',
    'hero.word2': 'verlässlicher.',
    'hero.word3': 'angenehmer.',
    'hero.sub': 'Eine akustische Schiene reinigt deine Zähne in 4 Minuten — komplett ohne Borsten.',
    'hero.cta': 'Auf die Warteliste',
    'hero.cta.subject': 'Warteliste',

    // ProductShowcase
    'showcase.alt': 'dentson Produkt',
    'showcase.stat1.value': '99',
    'showcase.stat1.unit': '%',
    'showcase.stat1.label': 'der Zahnoberflächen werden erreicht',
    'showcase.stat2.value': '0',
    'showcase.stat2.unit': ' Borsten',
    'showcase.stat2.label': 'reine Ultraschall-Reinigung',
    'showcase.stat3.value': '4',
    'showcase.stat3.unit': ' Min',
    'showcase.stat3.label': 'eine komplette Session, hands-free',
    'showcase.stat4.value': '250',
    'showcase.stat4.unit': '€',
    'showcase.stat4.label': 'gesparte Zahnreinigung pro Jahr',

    // StackCards intro
    'stack.eyebrow': 'Warum dentson',
    'stack.title.l1': 'Wir machen das,',
    'stack.title.l2': 'was eine Zahnbürste nicht kann.',

    // StackCards content
    'stack.card1.title': 'Erreicht 99% aller Oberflächen.',
    'stack.card1.f1': 'Ultraschall-Kavitation löst Plaque, Essensreste und Bakterien',
    'stack.card1.f2': 'Erreicht Zahnzwischenräume und Zahnfleischränder',
    'stack.card1.f3': 'Gründlich dort, wo Borsten nicht hinkommen',
    'stack.card2.title': 'Putzt komplett hands-free.',
    'stack.card2.f1': '4 Minuten für eine komplette Reinigung',
    'stack.card2.f2': 'Keine Putzfehler möglich, keine Anleitung nötig',
    'stack.card2.f3': 'Einsetzen und vergessen, du machst nebenbei etwas anderes',
    'stack.card3.title': 'Erkennt Karies, bevor sie weh tut.',
    'stack.card3.f1': 'Integrierte Sensorik misst Plaquedichte je Zahn',
    'stack.card3.f2': 'Kontinuierliches Monitoring des Kariesrisikos',
    'stack.card3.f3': 'Warnt, bevor Probleme sichtbar oder teuer werden',
    'stack.card4.title': 'Schluss mit professioneller Reinigung.',
    'stack.card4.f1': 'Ersetzt die halbjährliche Prophylaxe beim Zahnarzt',
    'stack.card4.f2': 'Spart 100 – 250 € an Dentalkosten pro Jahr',
    'stack.card4.f3': 'Klinik-Reinigungsleistung — zu Hause, in einer Minute',

    // BeforeAfterSlider labels
    'stack.ba.before': 'Zahnbelag vorher',
    'stack.ba.after': 'Zahnbelag nachher',

    // CavitationAnim caption
    'cav.caption': 'Kavitation · Ultraschall · Mikroblasen platzen',

    // Workflow
    'workflow.eyebrow': "So funktioniert's",
    'workflow.title': 'Die einfachste Zahnputzroutine.',
    'workflow.sub': 'Kein Schrubben. Keine Zahnseide. Keine Mundspülung.',
    'workflow.step1.title': 'Einschalten',
    'workflow.step1.desc': 'Ein Knopfdruck aktiviert den Reinigungsmodus.',
    'workflow.step2.title': 'Einsetzen',
    'workflow.step2.desc': 'Die Schiene in den Mund legen — Ober- und Unterkiefer gleichzeitig.',
    'workflow.step3.title': '4 Minuten warten',
    'workflow.step3.desc': 'Ultraschall reinigt berührungslos. Du machst währenddessen, worauf du Lust hast.',

    // Splits / Technology
    'split.tech.eyebrow': 'Die Technologie',
    'split.tech.title.l1': 'Mikroblasen statt',
    'split.tech.title.l2': 'Borsten.',
    'split.tech.text': 'Ultraschall-Wellen erzeugen in einer dünnen Wasserschicht rund um jeden Zahn mikroskopische Blasen. Platzen sie, lösen sich Plaque und Bakterien berührungslos. Damit reinigen wir Zähne deutlich effektiver und ohne Borsten.',

    // Roadmap
    'roadmap.kicker': 'Pre-launch · First acoustic dental cleaner',
    'roadmap.eyebrow': 'Roadmap',
    'roadmap.title': 'Wo wir stehen.',
    'roadmap.s1.title': 'Research',
    'roadmap.s1.desc': 'Technologie-Validierung mit Dentalpartnern.',
    'roadmap.s2.title': 'Prototyping',
    'roadmap.s2.desc': 'Funktionsfähige Hardware im Test.',
    'roadmap.s3.title': 'MVP',
    'roadmap.s3.desc': 'Erste Nutzer-Kohorte, klinische Validierung.',
    'roadmap.s4.title': 'Launch',
    'roadmap.s4.desc': 'Markteinführung dentson Start.',

    // Team
    'team.eyebrow': 'Team',
    'team.title.l1': 'Vier Gründer,',
    'team.title.l2': 'eine Mission.',
    'team.lead': 'Wir kombinieren Medtech-Engineering, Dentalchirurgie, Industriedesign und Go-to-Market zu einem Team, das Zahnpflege auf ein neues Niveau hebt.',
    'team.m1.role': 'Co-CEO · Engineering',
    'team.m2.role': 'Co-CEO · Dental Science',
    'team.m3.role': 'CPO · Industrial Design',
    'team.m4.role': 'CFO · Commercial',

    // Jobs
    'jobs.eyebrow': 'Careers',
    'jobs.title.l1': 'Offene',
    'jobs.title.l2': 'Stellen.',
    'jobs.initiative': 'Initiativbewerbung →',
    'jobs.openCount': 'offene Rollen',
    'jobs.metaType': 'Typ',
    'jobs.metaLocation': 'Ort',
    'jobs.metaGender': 'm/w/d',
    'jobs.metaGenderValue': 'Alle willkommen',
    'jobs.apply': 'Bewerben →',
    'jobs.moreInfo': 'Weitere Infos →',
    'jobs.prev': 'Previous',
    'jobs.next': 'Next',
    'jobs.fulltime': 'Vollzeit',
    'jobs.j1.title': 'Elektronikentwickler:in (m/w/d)',
    'jobs.j1.tag': 'Hardware',
    'jobs.j1.type': 'Vollzeit',
    'jobs.j1.location': 'Dresden · Hybrid',
    'jobs.j1.desc': 'Du designst die Sensorik- und Ultraschall-Platine der nächsten Generation.',
    'jobs.j2.title': 'Werkstudent:in Social Media (m/w/d)',
    'jobs.j2.tag': 'Marketing',
    'jobs.j2.type': 'Werkstudent:in',
    'jobs.j2.location': 'Dresden · Hybrid',
    'jobs.j2.desc': 'Du bringst dentson auf Social Media zum Leben – von der Content-Idee bis zum fertigen Video.',

    // Supporters
    'sup.eyebrow': 'Unsere Supporter',
    'sup.title': 'Gemeinsam eine neue Ära der Mundpflege eröffnen.',
    'sup.lead': 'Wir bauen die Zahnpflege der Zukunft und suchen Partner, Investoren und Kliniker, die mit uns eine Kategorie neu definieren wollen. Wenn Sie Teil dieser Reise werden möchten, freuen wir uns auf ein Gespräch.',
    'sup.cta': 'Get in touch',

    // Footer
    'footer.copy': '© 2026 dentson GmbH Dresden',
    'footer.imprint': 'Impressum',
    'footer.privacy': 'Datenschutz',
    'footer.agb': 'AGB',

    // Lang switcher
    'lang.de': 'Deutsch',
    'lang.en': 'English',

    // Showcase headline (Hero.jsx)
    'showcase.headline.l1': 'Wir machen',
    'showcase.headline.l2': 'das, was eine',
    'showcase.headline.l3': 'Zahnbürste',
    'showcase.headline.l4': 'nicht kann.',

    // TechSplit (Splits.jsx)
    'tech.headline.pre': 'Wir putzen mit',
    'tech.headline.em': 'Mikroblasen',
    'tech.headline.post': 'statt Borsten.',
    'tech.cta': 'Zu den Vorteilen',

    // Job detail page (JobDetail.jsx)
    'jd.gender': 'm/w/d',
    'jd.tasks': 'Deine Aufgaben',
    'jd.profile': 'Dein Profil',
    'jd.offer': 'Was wir dir bieten',
    'jd.apply.btn': 'Jetzt bewerben →',
    'jd.privacy.link': 'Datenschutzhinweis',
    'jd.sidebar.label': 'Weitere offene Stellen',
    'jd.sidebar.arrow': 'Zur Stelle →',
    'jd.initiative': 'Initiativbewerbung →',

    // Waitlist page (Waitlist.jsx)
    'wl.eyebrow': 'Tritt unserer Warteliste bei',
    'wl.mouthpiece.alt': 'dentson Mundstücke',
    'wl.success.title': 'Noch ein letzter Schritt',
    'wl.success.text': 'Bitte bestätige die Email in deinem Postfach (Überprüfe auch den Spam-Ordner)',
    'wl.success.back': 'Zurück zur Website',
    'wl.consent.text': 'Ich willige in die Aufnahme auf die Warteliste sowie in den Erhalt von E-Mails zum Produkt ein und akzeptiere die',
    'wl.consent.link': 'Datenschutzbestimmungen',
    'wl.submit': 'Senden',
    'wl.error.consent': 'Bitte akzeptiere die Datenschutzbestimmungen.',
    'wl.error.general': 'Etwas ist schiefgelaufen:',
  },

  en: {
    'doc.title': 'dentson — The first acoustic dental cleaner',

    'nav.product': 'Product',
    'nav.team': 'Team',
    'nav.jobs': 'Jobs',
    'nav.waitlist': 'Waitlist',

    'hero.line1': 'We make brushing teeth',
    'hero.word1': 'simpler.',
    'hero.word2': 'more reliable.',
    'hero.word3': 'more pleasant.',
    'hero.sub': 'An acoustic mouthpiece cleans your teeth in 4 minutes — completely without bristles.',
    'hero.cta': 'Join the waitlist',
    'hero.cta.subject': 'Waitlist',

    'showcase.alt': 'dentson product',
    'showcase.stat1.value': '99',
    'showcase.stat1.unit': '%',
    'showcase.stat1.label': 'of tooth surfaces are reached',
    'showcase.stat2.value': '0',
    'showcase.stat2.unit': ' bristles',
    'showcase.stat2.label': 'pure ultrasonic cleaning',
    'showcase.stat3.value': '4',
    'showcase.stat3.unit': ' min',
    'showcase.stat3.label': 'one complete session, hands-free',
    'showcase.stat4.value': '250',
    'showcase.stat4.unit': '€',
    'showcase.stat4.label': 'saved on dental cleanings per year',

    'stack.eyebrow': 'Why dentson',
    'stack.title.l1': 'We do what',
    'stack.title.l2': 'a toothbrush cannot.',

    'stack.card1.title': 'Reaches 99% of all surfaces.',
    'stack.card1.f1': 'Ultrasonic cavitation removes plaque, food residue and bacteria',
    'stack.card1.f2': 'Reaches interdental spaces and gum margins',
    'stack.card1.f3': 'Thorough where bristles cannot reach',
    'stack.card2.title': 'Cleans completely hands-free.',
    'stack.card2.f1': '4 minutes for a complete clean',
    'stack.card2.f2': 'No brushing mistakes possible, no instructions needed',
    'stack.card2.f3': 'Insert and forget, keep doing what you were doing',
    'stack.card3.title': 'Detects cavities before they hurt.',
    'stack.card3.f1': 'Integrated sensors measure plaque density per tooth',
    'stack.card3.f2': 'Continuous monitoring of cavity risk',
    'stack.card3.f3': 'Warns before issues become visible or expensive',
    'stack.card4.title': 'No more professional cleanings.',
    'stack.card4.f1': 'Replaces semi-annual dental prophylaxis',
    'stack.card4.f2': 'Saves €100 – 250 in dental costs per year',
    'stack.card4.f3': 'Clinical-grade cleaning — at home, in a minute',

    // BeforeAfterSlider labels
    'stack.ba.before': 'Dental plaque before',
    'stack.ba.after': 'Dental plaque after',

    // CavitationAnim caption
    'cav.caption': 'Cavitation · Ultrasound · Microbubbles collapsing',

    'workflow.eyebrow': 'How it works',
    'workflow.title': 'The simplest brushing routine.',
    'workflow.sub': 'No scrubbing. No floss. No mouthwash.',
    'workflow.step1.title': 'Power on',
    'workflow.step1.desc': 'One press activates cleaning mode.',
    'workflow.step2.title': 'Insert',
    'workflow.step2.desc': 'Place the mouthpiece — upper and lower jaw at the same time.',
    'workflow.step3.title': 'Wait 4 minutes',
    'workflow.step3.desc': 'Ultrasound cleans without contact. Do whatever you want in the meantime.',

    'split.tech.eyebrow': 'The technology',
    'split.tech.title.l1': 'Microbubbles instead of',
    'split.tech.title.l2': 'bristles.',
    'split.tech.text': 'Ultrasonic waves create microscopic bubbles in a thin water layer around every tooth. When they collapse, plaque and bacteria detach without contact. This cleans teeth significantly more effectively — and without bristles.',

    'roadmap.kicker': 'Pre-launch · First acoustic dental cleaner',
    'roadmap.eyebrow': 'Roadmap',
    'roadmap.title': 'Where we stand.',
    'roadmap.s1.title': 'Research',
    'roadmap.s1.desc': 'Technology validation with dental partners.',
    'roadmap.s2.title': 'Prototyping',
    'roadmap.s2.desc': 'Functional hardware in testing.',
    'roadmap.s3.title': 'MVP',
    'roadmap.s3.desc': 'First user cohort, clinical validation.',
    'roadmap.s4.title': 'Launch',
    'roadmap.s4.desc': 'Market launch of dentson Start.',

    'team.eyebrow': 'Team',
    'team.title.l1': 'Four founders,',
    'team.title.l2': 'one mission.',
    'team.lead': 'We combine medtech engineering, dental surgery, industrial design and go-to-market into one team that takes oral care to a new level.',
    'team.m1.role': 'Co-CEO · Engineering',
    'team.m2.role': 'Co-CEO · Dental Science',
    'team.m3.role': 'CPO · Industrial Design',
    'team.m4.role': 'CFO · Commercial',

    'jobs.eyebrow': 'Careers',
    'jobs.title.l1': 'Open',
    'jobs.title.l2': 'roles.',
    'jobs.initiative': 'Speculative application →',
    'jobs.openCount': 'open roles',
    'jobs.metaType': 'Type',
    'jobs.metaLocation': 'Location',
    'jobs.metaGender': 'f/m/d',
    'jobs.metaGenderValue': 'All welcome',
    'jobs.apply': 'Apply →',
    'jobs.moreInfo': 'Learn more →',
    'jobs.prev': 'Previous',
    'jobs.next': 'Next',
    'jobs.fulltime': 'Full-time',
    'jobs.j1.title': 'Electronics Engineer (m/f/d)',
    'jobs.j1.tag': 'Hardware',
    'jobs.j1.type': 'Full-time',
    'jobs.j1.location': 'Dresden · Hybrid',
    'jobs.j1.desc': 'You design the next-generation sensor and ultrasound board.',
    'jobs.j2.title': 'Working Student Social Media (m/f/d)',
    'jobs.j2.tag': 'Marketing',
    'jobs.j2.type': 'Working Student',
    'jobs.j2.location': 'Dresden · Hybrid',
    'jobs.j2.desc': 'You bring dentson to life on social media — from content idea to finished video.',

    'sup.eyebrow': 'Our supporters',
    'sup.title': 'Opening a new era of oral care, together.',
    'sup.lead': "We're building the future of dental care and looking for partners, investors and clinicians who want to redefine a category with us. If you'd like to be part of this journey, we'd love to talk.",
    'sup.cta': 'Get in touch',

    'footer.copy': '© 2026 dentson GmbH Dresden',
    'footer.imprint': 'Imprint',
    'footer.privacy': 'Privacy',
    'footer.agb': 'Terms',

    'lang.de': 'German',
    'lang.en': 'English',

    // Showcase headline (Hero.jsx)
    'showcase.headline.l1': 'We do',
    'showcase.headline.l2': 'what a',
    'showcase.headline.l3': 'toothbrush',
    'showcase.headline.l4': "can't.",

    // TechSplit (Splits.jsx)
    'tech.headline.pre': 'We clean with',
    'tech.headline.em': 'microbubbles',
    'tech.headline.post': 'instead of bristles.',
    'tech.cta': 'See the benefits',

    // Job detail page (JobDetail.jsx)
    'jd.gender': 'm/f/d',
    'jd.tasks': 'Your tasks',
    'jd.profile': 'Your profile',
    'jd.offer': 'What we offer',
    'jd.apply.btn': 'Apply now →',
    'jd.privacy.link': 'Privacy notice',
    'jd.sidebar.label': 'More open positions',
    'jd.sidebar.arrow': 'View role →',
    'jd.initiative': 'Unsolicited application →',

    // Waitlist page (Waitlist.jsx)
    'wl.eyebrow': 'Join our waitlist',
    'wl.mouthpiece.alt': 'dentson mouthpieces',
    'wl.success.title': 'One last step',
    'wl.success.text': 'Please confirm your email in your inbox (check your spam folder too)',
    'wl.success.back': 'Back to website',
    'wl.consent.text': 'I consent to being added to the waitlist and receiving product emails, and accept the',
    'wl.consent.link': 'privacy policy',
    'wl.submit': 'Submit',
    'wl.error.consent': 'Please accept the privacy policy.',
    'wl.error.general': 'Something went wrong:',
  },
};

function detectInitialLang() {
  try {
    const stored = localStorage.getItem('dentson.lang');
    if (stored === 'de' || stored === 'en') return stored;
  } catch (e) {}
  const browser = (navigator.language || 'de').toLowerCase();
  return browser.startsWith('de') ? 'de' : 'en';
}

const ACTIVE_LANG = detectInitialLang();

document.documentElement.lang = ACTIVE_LANG;
{
  const dict = TRANSLATIONS[ACTIVE_LANG] || TRANSLATIONS.de;
  if (dict['doc.title']) document.title = dict['doc.title'];
}

function translate(key) {
  const dict = TRANSLATIONS[ACTIVE_LANG] || TRANSLATIONS.de;
  return dict[key] !== undefined ? dict[key] : (TRANSLATIONS.de[key] || key);
}

function switchLang(target) {
  if (target === ACTIVE_LANG) return;
  try { localStorage.setItem('dentson.lang', target); } catch (e) {}
  window.location.reload();
}

function I18nProvider({ children }) {
  return children;
}

function useT() {
  return { lang: ACTIVE_LANG, setLang: switchLang, t: translate };
}

function FlagDE() {
  return (
    <svg viewBox="0 0 5 3" preserveAspectRatio="none" className="lang-flag" aria-hidden="true">
      <rect width="5" height="1" y="0" fill="#000" />
      <rect width="5" height="1" y="1" fill="#dd0000" />
      <rect width="5" height="1" y="2" fill="#ffce00" />
    </svg>
  );
}

function FlagGB() {
  return (
    <svg viewBox="0 0 60 30" preserveAspectRatio="none" className="lang-flag" aria-hidden="true">
      <clipPath id="lang-uk-clip"><path d="M0,0 v30 h60 v-30 z"/></clipPath>
      <clipPath id="lang-uk-clip2"><path d="M30,15 h30 v15 z v15 h-30 z h-30 v-15 z v-15 h30 z"/></clipPath>
      <g clipPath="url(#lang-uk-clip)">
        <path d="M0,0 v30 h60 v-30 z" fill="#012169"/>
        <path d="M0,0 L60,30 M60,0 L0,30" stroke="#fff" strokeWidth="6"/>
        <path d="M0,0 L60,30 M60,0 L0,30" clipPath="url(#lang-uk-clip2)" stroke="#C8102E" strokeWidth="4"/>
        <path d="M30,0 v30 M0,15 h60" stroke="#fff" strokeWidth="10"/>
        <path d="M30,0 v30 M0,15 h60" stroke="#C8102E" strokeWidth="6"/>
      </g>
    </svg>
  );
}

function LangSwitcher() {
  const { lang, setLang, t } = useT();
  return (
    <div className="lang-switcher" role="group" aria-label="Language">
      <button
        type="button"
        className={`lang-btn ${lang === 'de' ? 'on' : ''}`}
        onClick={() => setLang('de')}
        aria-label={t('lang.de')}
        aria-pressed={lang === 'de'}
      >
        <FlagDE />
      </button>
      <button
        type="button"
        className={`lang-btn ${lang === 'en' ? 'on' : ''}`}
        onClick={() => setLang('en')}
        aria-label={t('lang.en')}
        aria-pressed={lang === 'en'}
      >
        <FlagGB />
      </button>
    </div>
  );
}

window.I18nProvider = I18nProvider;
window.useT = useT;
window.LangSwitcher = LangSwitcher;
