:root {
    /* ── EuropeSoftwares — Palette Officielle ───────────────── */

    /* Fonds */
    --bg:      #f5f7fa;      /* Light grey premium */
    --bg2:     #ffffff;      /* Panels / cards */
    --bg3:     #eef1f4;      /* Inputs / secondary blocks */
    --bg4:     #dfe3e8;      /* Progress / separators */

    /* Bordures */
    --border:  rgba(0,0,0,0.10);
    --border2: rgba(0,0,0,0.18);
    --border3: rgba(0,0,0,0.28);

    /* Accent EuropeSoftwares */
    --accent:  #dd5132;      /* Jaune‑vert signature */
    --accent2: #995132;      /* Variante foncée */

    /* Texte */
    --text:    #1a1a1a;
    --muted:   #5f6b7a;      /* Gris technique */
    --muted2:  #8a96a8;      /* Gris clair */

    /* États */
    --danger:  #d64545;
    --success: #1fa86a;
    --info:    #2f7dd1;      /* Bleu EuropeSoftwares */
    --warn:    #d68a00;

    /* Rayons */
    --card-r:  12px;
    --r:       8px;
    --r-sm:    5px;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    min-height: 100vh;
}
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg3); }
::-webkit-scrollbar-thumb { background: var(--border3); border-radius: 99px; }

/* ── Header ────────────────────────────────────────────────── */
.tb-header {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    height: 58px;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 200;
}
.tb-logo {
    display: flex;
    align-items: center;
    gap: 9px;
    font-family: 'Syne', sans-serif;
    font-size: 18px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -.4px;
    flex-shrink: 0;
}
.tb-logo-icon {
    width: 30px; height: 30px;
    background: var(--accent);
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    color: #ffffff;
}
.tb-tagline {
    font-size: 12px;
    color: var(--muted);
    padding-left: 1.25rem;
    border-left: 1px solid var(--border2);
    white-space: nowrap;
}
.tb-badge {
    font-family: 'DM Mono', monospace;
    font-size: 10.5px;
    padding: 4px 11px;
    border-radius: 99px;
    background: rgba(180,200,0,.12);
    color: var(--accent);
    border: 1px solid rgba(180,200,0,.25);
    white-space: nowrap;
}
.tb-lang-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-end;
    margin-left: auto;
    max-width: 560px;
}
.tb-lang-flag {
    display: inline-flex;
    line-height: 0;
}
.tb-lang-flag img {
    border: solid 3px transparent;
    height: 32px;
    width: 32px;
}
.tb-lang-flag:hover img,
.tb-lang-flag.active img {
    border-color: red;
}

/* ── Layout principal ──────────────────────────────────────── */
.tb-layout {
    display: grid;
    grid-template-columns: 234px 1fr;
    min-height: calc(100vh - 58px);
}

/* ── Sidebar ───────────────────────────────────────────────── */
.tb-sidebar {
    background: var(--bg2);
    border-right: 1px solid var(--border);
    padding: 1.25rem 0 2rem;
    position: sticky;
    top: 58px;
    height: calc(100vh - 58px);
    overflow-y: auto;
}
.tb-section-label {
    font-family: 'DM Mono', monospace;
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: 1.6px;
    color: var(--muted2);
    padding: 0 .6rem .55rem;
    display: block;
}
.tb-divider { height: 1px; background: var(--border); margin: .3rem .75rem .9rem; }
.tb-nav-btn {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: var(--r);
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    text-align: left;
    transition: background .12s, color .12s;
    border-left: 2px solid transparent;
}
.tb-nav-btn:hover { background: var(--bg3); color: var(--text); }
.tb-nav-btn.active {
    background: rgba(180,200,0,.12);
    color: var(--accent);
    border-left-color: var(--accent);
}

/* ── Contenu principal ─────────────────────────────────────── */
.tb-main { padding: 2rem; max-width: 920px; }

/* ── Panels ────────────────────────────────────────────────── */
.tb-panel { display: none; animation: tbFadeIn .18s ease both; }
.tb-panel.active { display: block; }
@keyframes tbFadeIn { from { opacity:0; transform:translateY(5px); } to { opacity:1; transform:none; } }

.tb-panel-title {
    font-family: 'Syne', sans-serif;
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 5px;
}
.tb-panel-desc { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 1.5rem; }

/* ── Dropzone ─────────────────────────────────────────────── */
.tb-dropzone {
    position: relative;
    border: 1.5px dashed var(--border2);
    border-radius: var(--card-r);
    padding: 2.8rem 2rem;
    text-align: center;
    background: var(--bg2);
    transition: border-color .18s, background .18s;
    cursor: pointer;
}
.tb-dropzone:hover,
.tb-dropzone.over {
    border-color: var(--accent);
    background: rgba(180,200,0,.06);
}
.tb-dz-icon {
    width: 48px; height: 48px;
    background: var(--bg3);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: var(--accent);
    margin: 0 auto .9rem;
}
.tb-dz-title { font-size: 15px; font-weight: 500; margin-bottom: 5px; }
.tb-dz-hint  { font-size: 12px; color: var(--muted); }

/* ── File list ─────────────────────────────────────────────── */
.tb-file-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 11px;
    background: var(--bg3);
    border-radius: var(--r);
    border: 1px solid var(--border);
}
.tb-badge-ext {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(180,200,0,.12);
    color: var(--accent2);
}
.tb-badge-ext.img { background: rgba(47,125,209,.12); color: var(--info); }

/* ── Boutons ───────────────────────────────────────────────── */
.tb-btn-primary { background: var(--accent); color: #ffffff; }
.tb-btn-primary:hover:not(:disabled) { background: var(--accent2); }

.tb-btn-ghost  {
    background: var(--bg3);
    color: var(--text);
    border: 1px solid var(--border2);
}
.tb-btn-ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.tb-btn-danger {
    background: rgba(214,69,69,.12);
    color: var(--danger);
    border: 1px solid rgba(214,69,69,.25);
}
.tb-btn-danger:hover:not(:disabled) { background: rgba(214,69,69,.22); }

/* ── Cartes ────────────────────────────────────────────────── */
.tb-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--card-r);
    padding: 1.15rem 1.2rem;
    margin-bottom: .9rem;
}
.tb-card-title {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--muted);
    margin-bottom: .9rem;
}

/* ── Formulaires ───────────────────────────────────────────── */
.tb-input, .tb-select, .tb-textarea {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border2);
    color: var(--text);
    padding: 8px 11px;
    border-radius: var(--r);
    font-size: 13px;
    transition: border-color .15s;
}
.tb-input:focus, .tb-select:focus, .tb-textarea:focus { border-color: var(--accent); }

/* ── Status / alertes ──────────────────────────────────────── */
.tb-status.success { background: rgba(31,168,106,.10); border: 1px solid rgba(31,168,106,.25); color: var(--success); }
.tb-status.error   { background: rgba(214,69,69,.10);  border: 1px solid rgba(214,69,69,.25);  color: var(--danger);  }
.tb-status.info    { background: rgba(47,125,209,.10); border: 1px solid rgba(47,125,209,.25); color: var(--info);    }
.tb-status.warning { background: rgba(214,138,0,.10);  border: 1px solid rgba(214,138,0,.25);  color: var(--warn);    }

/* ── Progress bar ──────────────────────────────────────────── */
.tb-progress { background: var(--bg4); }
.tb-progress-bar { background: var(--accent); }

/* ── Download card ─────────────────────────────────────────── */
.tb-dl-card {
    background: rgba(31,168,106,.08);
    border: 1px solid rgba(31,168,106,.25);
}

/* ── Thumbnail grid ────────────────────────────────────────── */
.tb-thumb-card {
    background: var(--bg3);
    border: 1px solid var(--border);
}
.tb-thumb-card:hover { border-color: var(--border3); }
.tb-thumb-card.selected { border-color: var(--accent); background: rgba(180,200,0,.08); }
.tb-rot-badge {
    background: rgba(180,200,0,.18);
    color: var(--accent2);
}

/* ── Filigrane preview ─────────────────────────────────────── */
.tb-wm-preview { background: #ffffff; }
.tb-wm-preview-inner { background: #ffffff; border: 1px solid #ccc; }
.tb-wm-text { color: rgba(100,100,100,.25); }

/* ── Metadata table ────────────────────────────────────────── */
.tb-meta-table tr { border-bottom: 1px solid var(--border); }
.tb-meta-table td:first-child { color: var(--muted); }

/* ── Viewer ────────────────────────────────────────────────── */
.tb-viewer-wrap {
    background: #e6e6e6;
}
.tb-viewer-wrap canvas { box-shadow: 0 2px 16px rgba(0,0,0,.15); }

/* ── Chips ─────────────────────────────────────────────────── */
.tb-chip {
    border: 1px solid var(--border2);
    background: var(--bg3);
    color: var(--muted);
}
.tb-chip:hover { border-color: var(--accent); color: var(--accent); }

/* ── Toast ─────────────────────────────────────────────────── */
.tb-toast-inner {
    background: var(--bg2);
    border: 1px solid var(--border2);
    box-shadow: 0 8px 30px rgba(0,0,0,.15);
}

/* ── Right workspace refinement ───────────────────────────── */
.tb-layout {
    grid-template-columns: 252px minmax(0, 1fr);
}
.tb-main {
    max-width: none;
    min-width: 0;
    padding: clamp(1.25rem, 2.4vw, 2.6rem);
}
.tb-panel.active {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 1rem;
    max-width: 1040px;
}
.tb-panel-title,
.tb-panel-desc {
    grid-column: 1 / -1;
}
.tb-panel-title {
    font-size: clamp(23px, 2.1vw, 32px);
    line-height: 1.08;
}
.tb-panel-desc {
    max-width: 760px;
    margin-bottom: .35rem;
}
.tb-dropzone,
.tb-file-list,
.tb-dl-list,
.tb-progress {
    grid-column: 1 / -1;
}
.tb-panel > .tb-card,
.tb-panel > .tb-grid2,
.tb-panel > button,
.tb-panel > [style*="display:flex"],
.tb-panel > [style*="margin-top"] {
    grid-column: 1 / -1;
}
.tb-panel > [id^="stat-"] {
    grid-column: 1 / -1;
    min-height: 0;
}
#pan-preview.active,
#pan-rotate.active,
#pan-reorder.active,
#pan-metadata.active,
#pan-watermark.active {
    grid-template-columns: minmax(0, 1fr);
}
#pan-preview > .tb-panel-title,
#pan-preview > .tb-panel-desc,
#pan-rotate > .tb-panel-title,
#pan-rotate > .tb-panel-desc,
#pan-reorder > .tb-panel-title,
#pan-reorder > .tb-panel-desc,
#pan-metadata > .tb-panel-title,
#pan-metadata > .tb-panel-desc,
#pan-watermark > .tb-panel-title,
#pan-watermark > .tb-panel-desc {
    grid-column: 1 / -1;
}
#rotate-controls,
#reorder-area,
#meta-edit-area,
#preview-area,
#pan-watermark > .tb-grid2,
#pan-watermark > #btn-watermark,
#pan-watermark > #stat-watermark {
    grid-column: 1 / -1;
}
.tb-dropzone {
    min-height: 245px;
    display: grid;
    place-items: center;
    align-content: center;
}
.tb-file-list,
.tb-dl-list {
    display: grid;
    gap: .55rem;
    margin-top: -.25rem;
}
.tb-btn {
    align-items: center;
    border: 1px solid transparent;
    border-radius: var(--r);
    display: inline-flex;
    font-size: 13px;
    font-weight: 600;
    gap: 7px;
    justify-content: center;
    min-height: 38px;
    padding: 9px 13px;
    transition: background .15s, border-color .15s, color .15s, opacity .15s;
}
.tb-btn:disabled {
    cursor: not-allowed;
    opacity: .52;
}
.tb-btn-sm {
    min-height: 30px;
    padding: 6px 9px;
}
.tb-card {
    box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.tb-card + .tb-card {
    margin-top: .2rem;
}
.tb-card {
    align-items: end;
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
}
.tb-card-title {
    flex: 0 0 100%;
    margin-bottom: .15rem;
}
.tb-card > .tb-check-row,
.tb-card > .tb-form-group,
.tb-card > .tb-grid2,
.tb-card > .tb-chips,
.tb-card > table,
.tb-card > button {
    flex: 1 1 180px;
}
.tb-card > .tb-grid2 {
    min-width: 100%;
}
#pan-convert .tb-card > .tb-grid2,
#pan-protect .tb-card > .tb-grid2,
#pan-watermark .tb-card > .tb-grid2,
#meta-edit-area .tb-card > .tb-grid2 {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}
#pan-preview .tb-card,
#pan-watermark .tb-card:nth-child(2) {
    display: block;
}
.tb-viewer-toolbar,
.tb-viewer-wrap,
.tb-wm-preview,
.tb-meta-table {
    width: 100%;
}
.tb-grid2 {
    display: grid;
    gap: .85rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.tb-grid4 {
    display: grid;
    gap: .75rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
.tb-form-group {
    display: grid;
    gap: .35rem;
}
.tb-label {
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 600;
}
.tb-check-row {
    align-items: center;
    display: flex;
    gap: .55rem;
    min-height: 32px;
}
.tb-check-row + .tb-check-row {
    margin-top: 0;
}
.tb-input,
.tb-select,
.tb-textarea {
    min-height: 38px;
}
.tb-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
}
.tb-chip {
    border-radius: 999px;
    font-size: 12px;
    min-height: 28px;
    padding: 5px 10px;
}
.tb-status {
    border-radius: var(--r);
    font-size: 13px;
    padding: 10px 12px;
}
.tb-progress {
    border-radius: 999px;
    display: none;
    height: 8px;
    overflow: hidden;
}
.tb-progress-bar {
    height: 100%;
    transition: width .2s ease;
    width: 0;
}
.tb-dl-card,
.tb-dl-row {
    align-items: center;
    border-radius: var(--r);
    display: flex;
    gap: .8rem;
    padding: .8rem;
}
.tb-dl-row {
    background: var(--bg3);
    border: 1px solid var(--border);
}
.tb-dl-info,
.fname {
    min-width: 0;
}
.tb-dl-name,
.fname {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fsize,
.tb-dl-size {
    color: var(--muted);
    font-size: 12px;
    margin-left: auto;
    white-space: nowrap;
}
.fdel {
    align-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50%;
    color: var(--muted);
    display: inline-flex;
    flex: 0 0 26px;
    height: 26px;
    justify-content: center;
}
.fdel:hover {
    border-color: rgba(214,69,69,.3);
    color: var(--danger);
}
.tb-thumb-grid {
    display: grid;
    gap: .75rem;
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
}
.tb-thumb-card {
    border-radius: var(--r);
    cursor: pointer;
    padding: .6rem;
    position: relative;
}
.tb-thumb-card canvas {
    background: #fff;
    border-radius: 4px;
    display: block;
    margin: 0 auto .45rem;
    max-width: 100%;
}
.tb-thumb-label {
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}
.tb-rot-badge {
    border-radius: 999px;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    padding: 2px 6px;
    position: absolute;
    right: 8px;
    top: 8px;
}
.tb-meta-table {
    border-collapse: collapse;
    width: 100%;
}
.tb-meta-table td {
    padding: .55rem .25rem;
    vertical-align: top;
}
.tb-viewer-toolbar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
}
.tb-page-info {
    color: var(--muted);
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    min-width: 110px;
    text-align: center;
}
.tb-viewer-wrap {
    border-radius: var(--r);
    margin-top: .85rem;
    max-height: 68vh;
    overflow: auto;
    padding: 1rem;
    text-align: center;
}
.tb-stat {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: .85rem;
}
.tb-stat-label {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
}
.tb-stat-value {
    font-family: 'Syne', sans-serif;
    font-size: 22px;
    font-weight: 700;
}
.tb-stat-unit {
    color: var(--muted);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 12px;
}
.tb-wm-preview {
    border-radius: var(--r);
    padding: .8rem;
}
.tb-wm-preview-inner {
    align-items: center;
    aspect-ratio: 1 / 1.35;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    min-height: 240px;
    overflow: hidden;
}
.tb-wm-text {
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    max-width: 90%;
    overflow-wrap: anywhere;
    text-align: center;
}

@media (max-width: 1120px) {
    .tb-header {
        height: auto;
        min-height: 58px;
        flex-wrap: wrap;
        padding-bottom: .65rem;
        padding-top: .65rem;
    }
    .tb-layout {
        min-height: calc(100vh - 74px);
    }
    .tb-sidebar {
        top: 74px;
        height: calc(100vh - 74px);
    }
    .tb-tagline,
    .tb-badge {
        display: none;
    }
    .tb-panel.active {
        grid-template-columns: minmax(0, 1fr);
    }
    .tb-panel > .tb-card,
    .tb-panel > .tb-grid2,
    .tb-panel > button,
    .tb-panel > [style*="display:flex"],
    .tb-panel > [style*="margin-top"],
    .tb-panel > [id^="stat-"] {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .tb-layout {
        display: block;
    }
    .tb-sidebar {
        border-bottom: 1px solid var(--border);
        border-right: 0;
        height: auto;
        max-height: none;
        overflow: visible;
        padding: .8rem;
        position: static;
    }
    .tb-sidebar-section {
        display: flex;
        gap: .45rem;
        overflow-x: auto;
        padding-bottom: .35rem;
    }
    .tb-section-label,
    .tb-divider {
        display: none;
    }
    .tb-nav-btn {
        flex: 0 0 auto;
        width: auto;
    }
    .tb-main {
        padding: 1rem;
    }
    .tb-grid2,
    .tb-grid4 {
        grid-template-columns: 1fr;
    }
    .tb-dropzone {
        min-height: 210px;
        padding: 2rem 1rem;
    }
    .tb-lang-flags {
        justify-content: flex-start;
        margin-left: 0;
        max-width: 100%;
        width: 100%;
    }
}

/* ── Champ mot de passe avec bouton afficher/masquer ───────── */
.tb-pass-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.tb-pass-wrap .tb-input {
    padding-right: 38px;
}
.tb-pass-toggle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 36px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    border-radius: 0 var(--r) var(--r) 0;
    transition: color .15s;
    padding: 0;
}
.tb-pass-toggle:hover { color: var(--text); }
.tb-pass-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* ── Bouton générer mot de passe ───────────────────────────── */
.tb-gen-pass-row {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-top: .65rem;
}
.tb-btn-gen-pass {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: var(--bg3);
    border: 1px solid var(--border2);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: var(--r);
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
    white-space: nowrap;
}
.tb-btn-gen-pass:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.tb-btn-gen-pass:hover svg { stroke: #fff; }
.tb-btn-gen-pass:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.tb-gen-pass-hint {
    font-size: 11px;
    color: var(--muted);
    font-family: monospace;
    letter-spacing: .04em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
    opacity: 0;
    transition: opacity .25s;
}
.tb-gen-pass-hint.visible { opacity: 1; }
