:root { --bg-dark: #121212; --panel-bg: #1e1e1e; --accent: #007aff; }
body { margin: 0; display: flex; height: 100vh; font-family: -apple-system, sans-serif; background: var(--bg-dark); color: white; overflow: hidden; }

#sidebar { width: 300px; background: var(--panel-bg); border-right: 1px solid #333; display: flex; flex-direction: column; z-index: 100; box-shadow: 2px 0 10px rgba(0,0,0,0.5); }
.header { padding: 12px 20px; border-bottom: 1px solid #333; min-height: 72px; box-sizing: border-box; display: flex; align-items: stretch; }
.content { padding: 20px; flex-grow: 1; overflow-y: auto; }

select { width: 100%; padding: 12px; background: #333; border: 1px solid #444; color: white; border-radius: 6px; margin-bottom: 20px; outline: none; }

#thumbnail-toggle { margin-bottom: 8px; }
#thumbnail-toggle button { width: 100%; padding: 8px 12px; background: #333; border: 1px solid #444; color: #aaa; border-radius: 6px; font-size: 12px; cursor: pointer; }
#thumbnail-toggle button:hover { background: #3a3a3a; color: #fff; }
#thumbnail-wrap { margin-bottom: 16px; display: none; border-radius: 8px; overflow: hidden; background: #1a1a1a; min-height: 120px; padding: 10px; box-sizing: border-box; }
#thumbnail-wrap.visible { display: block; }
#thumbnail-wrap img { width: 100%; height: auto; display: block; max-height: 280px; object-fit: contain; }
#thumbnail-wrap .thumb-label { font-size: 11px; color: #666; padding: 6px 8px; }
#thumbnail-wrap .thumb-error { font-size: 12px; color: #888; padding: 20px; text-align: center; display: none; }

#metadata-card { background: #2a2a2a; padding: 15px; border-radius: 8px; font-size: 13px; display: none; }
.tile-source-card { background: #2a2a2a; padding: 15px; border-radius: 8px; font-size: 12px; margin-top: 12px; }
.tile-source-card .meta-item { display: flex; justify-content: space-between; margin-bottom: 6px; border-bottom: 1px solid #383838; padding-bottom: 4px; }
.tile-source-card .meta-label { color: #888; }
.metadata-card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.metadata-card-header h4 { flex: 1; }
.slide-qrcode-mini { flex-shrink: 0; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; }
#slide-qrcode-wrap.no-slide { display: none !important; }
#slide-qrcode-wrap #slide-qrcode canvas,
#slide-qrcode-wrap #slide-qrcode img { display: block; max-width: 100%; max-height: 100%; }
.meta-item { display: flex; justify-content: space-between; margin-bottom: 8px; border-bottom: 1px solid #383838; padding-bottom: 4px; }
.meta-label { color: #888; }

#layers-panel { margin-top: 20px; }
#layers-panel.no-slide { opacity: 0.6; pointer-events: none; }
#layers-panel h4 { margin: 0 0 10px 0; font-size: 12px; color: var(--accent); }
#layers-panel select { margin-bottom: 8px; font-size: 11px; padding: 8px 10px; }
#layers-panel .opacity-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
#layers-panel .opacity-row input[type="range"] { flex: 1; accent-color: #0d9488; }
#layers-panel .opacity-row span { font-size: 11px; color: #888; min-width: 32px; }
#layers-panel .overlay-pipeline-steps {
    margin-top: 8px; padding: 8px; font-size: 10px; line-height: 1.4;
    background: rgba(0,0,0,0.25); border-radius: 6px; border-left: 3px solid var(--accent);
    color: #bbb;
}
#layers-panel .overlay-pipeline-steps strong { color: #ddd; }
#layers-panel .overlay-pipeline-steps em { color: #0d9488; font-style: normal; }
#layers-panel .overlay-check-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 10px; color: #ccc; cursor: pointer; }
#layers-panel .overlay-check-row input { cursor: pointer; }
.layer-category { font-size: 11px; color: #666; margin-top: 4px; }

#viewer-container { flex-grow: 1; position: relative; background: var(--panel-bg); }
#viewer { width: 100%; height: 100%; }

/* Plein écran toute l'appli (API sur documentElement, ou fallback CSS sur body) */
body.app-fullscreen-mode {
    position: fixed !important;
    top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    width: 100vw !important; height: 100vh !important;
    z-index: 9999 !important;
}
html:fullscreen, html:-webkit-full-screen, html:-moz-full-screen, html:-ms-fullscreen { background: var(--panel-bg); }

/* Mode comparaison : split deux lames */
.viewer-container-comparison {
    flex-grow: 1;
    display: flex;
    flex-direction: row;
    position: relative;
    background: var(--panel-bg);
    min-height: 0;
}
.viewer-container-comparison .comparison-viewer-left {
    flex: 0 0 50%;
    min-width: 120px;
    max-width: calc(100% - 120px - 12px);
    position: relative;
    display: flex;
    flex-direction: column;
}
.viewer-container-comparison .comparison-viewer-right {
    flex: 1;
    min-width: 120px;
    position: relative;
    display: flex;
    flex-direction: column;
}
.viewer-container-comparison .comparison-viewer-wrap {
    min-width: 0;
}
.comparison-split-divider {
    flex: 0 0 12px;
    width: 12px;
    background: var(--border, #333);
    cursor: col-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 10;
}
.comparison-split-divider:hover,
.comparison-split-divider.dragging {
    background: var(--accent);
}
.comparison-split-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 6px;
    height: 48px;
    background: rgba(255,255,255,0.4);
    border-radius: 3px;
    pointer-events: none;
    font-size: 14px;
    line-height: 1;
    color: rgba(255,255,255,0.8);
}
.comparison-split-divider:hover .comparison-split-handle,
.comparison-split-divider.dragging .comparison-split-handle {
    background: rgba(255,255,255,0.9);
}
.viewer-container-comparison .comparison-viewer {
    width: 100%;
    height: 100%;
    min-height: 200px;
}
.viewer-container-comparison .comparison-viewer-label {
    position: absolute;
    bottom: 8px;
    left: 8px;
    font-size: 11px;
    color: var(--text-muted, #888);
    background: rgba(0,0,0,0.5);
    padding: 2px 8px;
    border-radius: 4px;
    pointer-events: none;
}
.comparison-enter-btn {
    width: 100%;
    margin-top: 10px;
    padding: 10px 14px;
    font-size: 12px;
    color: var(--accent);
    background: transparent;
    border: 1px solid var(--accent);
    border-radius: var(--neuro-radius, 8px);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.comparison-enter-btn:hover { background: var(--accent); color: #fff; }
.comparison-mode-panel .section-label { display: block; }
.comparison-mode-panel select { width: 100%; margin-bottom: 0; }
.comparison-sync-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted, #888);
    cursor: pointer;
}
.comparison-sync-row input { cursor: pointer; }
.comparison-exit-btn {
    width: 100%;
    margin-top: 12px;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--neuro-radius, 8px);
    cursor: pointer;
}
.comparison-exit-btn:hover { background: var(--border); }
body.theme-light-neuro .comparison-split-divider { background: var(--border); }
body.theme-light-neuro .comparison-split-divider:hover,
body.theme-light-neuro .comparison-split-divider.dragging { background: var(--accent); }
body.theme-light-neuro .comparison-split-handle { background: rgba(0,0,0,0.25); color: rgba(0,0,0,0.7); }
body.theme-light-neuro .comparison-split-divider:hover .comparison-split-handle,
body.theme-light-neuro .comparison-split-divider.dragging .comparison-split-handle { background: rgba(0,0,0,0.5); color: #000; }

.header-inner { display: flex; align-items: center; justify-content: center; width: 100%; height: 60px; box-sizing: border-box; position: relative; }
.header-logo { width: 100%; height: 60px; object-fit: contain; object-position: center; display: block; }
.sidebar-footer { flex-shrink: 0; padding: 6px 16px; border-top: 1px solid var(--border, #333); }
.sidebar-footer-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.sidebar-footer-row .sidebar-user-name {
    flex: 1;
    min-width: 0;
    font-size: 10px;
    color: var(--text-muted, #888);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#admin-link-wrap { flex-shrink: 0; }
.admin-link-bottom {
    flex: 1;
    display: block;
    text-align: center;
    padding: 6px 10px;
    font-size: 11px;
    color: var(--accent);
    text-decoration: none;
    border-radius: var(--neuro-radius, 8px);
    border: 1px solid var(--accent);
    background: transparent;
    transition: background 0.15s, color 0.15s;
}
.admin-link-bottom:hover { background: var(--accent); color: #fff; }
.sidebar-footer .logout-btn-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    padding: 0;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted, #888);
    border: 1px solid var(--border, #444);
    background: transparent;
    border-radius: var(--neuro-radius, 8px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.sidebar-footer .logout-btn-icon:hover {
    background: rgba(185, 28, 28, 0.15);
    border-color: rgba(185, 28, 28, 0.5);
    color: #b91c1c;
}
.sidebar-footer .logout-btn-icon { position: relative; }
.sidebar-footer .logout-btn-icon > span:first-of-type { display: block; }
.sidebar-footer .logout-btn-icon .logout-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    padding: 6px 10px;
    font-size: 11px;
    white-space: nowrap;
    background: var(--panel-bg, #2a2a2a);
    color: var(--text, #eee);
    border-radius: 6px;
    border: 1px solid var(--border, #444);
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.sidebar-footer .logout-btn-icon:hover .logout-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}
body.theme-light-neuro .sidebar-footer .logout-btn-icon .logout-tooltip {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
    box-shadow: var(--shadow-soft);
}
body.theme-light-neuro .sidebar-footer { border-top-color: var(--border); }
body.theme-light-neuro .admin-link-bottom { color: var(--accent); border-color: var(--accent); }
body.theme-light-neuro .admin-link-bottom:hover { background: var(--accent); color: #fff; }
body.theme-light-neuro .sidebar-footer .logout-btn-icon { color: var(--text-muted); border-color: var(--border); }
body.theme-light-neuro .sidebar-footer .logout-btn-icon:hover {
    background: rgba(185, 28, 28, 0.12);
    border-color: rgba(185, 28, 28, 0.4);
    color: #b91c1c;
}

/* Laboratoire (compte) — taille réduite */
#gateway-labo-wrap.gateway-row .gateway-sublabel {
    font-size: 11px;
    color: #888;
    margin-bottom: 4px;
    display: block;
}
#gateway-labo-wrap .gateway-input { font-size: 12px; padding: 8px 10px; }
body.theme-light-neuro #gateway-labo-wrap .gateway-sublabel { color: var(--text-muted); }

/* Bloc Lame distante (gateway) — harmonisé avec le reste de la sidebar */
#open-remote-row.gateway-row {
    margin-top: 20px;
    padding: 14px;
    background: #2a2a2a;
    border-radius: 8px;
    border: 1px solid #333;
}
#open-remote-row .gateway-label {
    display: block;
    margin: 0 0 12px 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}
#open-remote-row .gateway-sublabel {
    display: block;
    font-size: 11px;
    color: #888;
    margin-top: 10px;
    margin-bottom: 4px;
}
#open-remote-row .gateway-sublabel:first-of-type { margin-top: 0; }
#open-remote-row .gateway-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    background: #333;
    border: 1px solid #444;
    color: #fff;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}
#open-remote-row .gateway-input::placeholder { color: #666; }
#open-remote-row .gateway-input:focus { border-color: var(--accent); }
#open-remote-row .gateway-base-input { margin-bottom: 4px; }
#open-remote-row .gateway-btn {
    margin-top: 10px;
    padding: 8px 12px;
    background: #444;
    border: 1px solid #555;
    color: #e8e8e8;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    width: 100%;
}
#open-remote-row .gateway-btn:hover { background: #555; color: #fff; }
#open-remote-row .gateway-open-btn { background: var(--accent); border-color: var(--accent); color: #fff; }
#open-remote-row .gateway-open-btn:hover { filter: brightness(1.1); }
#open-remote-row .gateway-url-display {
    margin-top: 8px;
    font-size: 11px;
    color: #888;
    word-break: break-all;
    line-height: 1.3;
}
body.theme-light-neuro #open-remote-row .gateway-url-display { color: var(--text-muted); }

body.theme-light-neuro #open-remote-row.gateway-row {
    background: var(--surface-2);
    border-radius: var(--neuro-radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    padding: 14px;
}
body.theme-light-neuro #open-remote-row .gateway-label { color: var(--accent); }
body.theme-light-neuro #open-remote-row .gateway-sublabel { color: var(--text-muted); }
body.theme-light-neuro #open-remote-row .gateway-input {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--neuro-radius);
    box-shadow: var(--shadow-inset);
}
body.theme-light-neuro #open-remote-row .gateway-input::placeholder { color: var(--text-muted); opacity: 0.8; }
body.theme-light-neuro #open-remote-row .gateway-input:focus { border-color: var(--accent); }
body.theme-light-neuro #open-remote-row .gateway-btn {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--neuro-radius);
    box-shadow: var(--shadow-soft), var(--shadow-out);
}
body.theme-light-neuro #open-remote-row .gateway-btn:hover {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-inset);
}
body.theme-light-neuro #open-remote-row .gateway-open-btn {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: var(--shadow-soft);
}
body.theme-light-neuro #open-remote-row .gateway-open-btn:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-inset);
}

.openseadragon-navigator { border: 1px solid rgba(255,255,255,0.3) !important; border-radius: 6px !important; box-shadow: 0 2px 12px rgba(0,0,0,0.5) !important; }

#scale-bar { position: absolute; bottom: 16px; left: 16px; z-index: 10; display: none; align-items: flex-end; gap: 8px; pointer-events: none; }
#scale-bar .bar { background: white; height: 4px; min-width: 2px; box-shadow: 0 0 2px rgba(0,0,0,0.8); }
#scale-bar .label { color: white; font-size: 12px; font-family: -apple-system, sans-serif; text-shadow: 0 0 2px #000, 0 1px 2px #000; }

#zoom-level { position: absolute; bottom: 16px; right: 16px; z-index: 10; display: none; color: white; font-size: 12px; font-family: -apple-system, sans-serif; text-shadow: 0 0 2px #000, 0 1px 2px #000; pointer-events: none; }

#zones-panel { margin-top: 20px; }
#zones-panel.no-slide { opacity: 0.6; pointer-events: none; }
#zones-panel h4 { margin: 0 0 10px 0; font-size: 13px; color: var(--accent); }
#zones-panel .zones-toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
#zones-panel .zones-toolbar button { padding: 8px 12px; background: #444; border: 1px solid #555; color: #e8e8e8; border-radius: 6px; font-size: 12px; cursor: pointer; }
#zones-panel .zones-toolbar button:hover { background: #555; color: #fff; }
#zones-panel .zones-toolbar button.active { background: #0d9488; border-color: #0d9488; color: #fff; }
#zones-list { display: flex; flex-direction: column; gap: 10px; max-height: 320px; overflow-y: auto; }
#zones-list .zone-item { display: flex; align-items: center; gap: 10px; padding: 8px; background: #2a2a2a; border-radius: 8px; cursor: pointer; border: 1px solid #333; transition: background 0.15s; }
#zones-list .zone-item:hover { background: #333; border-color: var(--accent); }
#zones-list .zone-item img { width: 64px; height: 64px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
#zones-list .zone-item .zone-label { font-size: 12px; color: #ccc; }
#zones-list .zone-item .zone-delete { margin-left: auto; padding: 4px 8px; font-size: 11px; background: #444; border: none; border-radius: 4px; color: #aaa; cursor: pointer; }
#zones-list .zone-item .zone-delete:hover { background: #555; color: #fff; }
.zones-hint { font-size: 11px; color: #888; margin-top: 8px; margin-bottom: 0; }
body.theme-light-neuro .zones-hint { color: var(--text-muted); }
#selection-overlay { position: absolute; left: 0; top: 0; right: 0; bottom: 0; z-index: 20; display: none; cursor: crosshair; pointer-events: none; }
#selection-overlay.active { display: block; pointer-events: auto; }
#viewer-container.selection-mode #viewer { pointer-events: none; }
#selection-rect { position: absolute; border: 2px solid var(--accent); background: rgba(0,122,255,0.15); pointer-events: none; }

#annotations-panel { margin-top: 20px; }
#annotations-panel.no-slide { opacity: 0.6; pointer-events: none; }
#annotations-panel h4 { margin: 0 0 10px 0; font-size: 13px; color: var(--accent); }
#annotations-toolbar { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
#annotations-toolbar button { padding: 8px 10px; background: #333; border: 1px solid #444; color: #ccc; border-radius: 6px; font-size: 12px; cursor: pointer; }
#annotations-toolbar button:hover { background: #3a3a3a; color: #fff; }
#annotations-toolbar button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
#annotations-actions { display: flex; gap: 8px; margin-bottom: 10px; }
#annotations-actions button { padding: 8px 12px; background: #2a2a2a; border: 1px solid #444; color: #ccc; border-radius: 6px; font-size: 12px; cursor: pointer; }
#annotations-actions button:hover { background: #333; color: #fff; }
#annotations-actions button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
#annotation-color { width: 32px; height: 28px; padding: 0; border: 1px solid #444; border-radius: 4px; cursor: pointer; vertical-align: middle; }
#slide-url-input:focus { outline: none; border-color: var(--accent, #0d9488); }
#open-by-url-row .btn-load-url,
#open-by-folder-url-row .btn-load-url { padding: 8px 12px; background: #333; border: 1px solid #444; color: #ccc; border-radius: 6px; font-size: 12px; cursor: pointer; white-space: nowrap; }
#open-by-url-row .btn-load-url:hover,
#open-by-folder-url-row .btn-load-url:hover { background: #3a3a3a; color: #fff; }
body.theme-light-neuro #open-by-url-row .btn-load-url,
body.theme-light-neuro #open-by-folder-url-row .btn-load-url { background: var(--surface-2); border-color: var(--border); color: var(--text-muted); }
body.theme-light-neuro #open-by-url-row .btn-load-url:hover,
body.theme-light-neuro #open-by-folder-url-row .btn-load-url:hover { background: var(--surface-3); color: var(--text); }
#folder-url-input { outline: none; }
#folder-url-input:focus { outline: none; border-color: var(--accent, #0d9488); }
#annotations-list { max-height: 180px; overflow-y: auto; font-size: 12px; color: #888; }
#annotations-list .annotations-list-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid #333; cursor: pointer; min-height: 28px; }
#annotations-list .annotations-list-row:hover { background: rgba(255,255,255,0.04); }
#annotations-list .annotations-list-label { flex: 1; min-width: 0; color: #aaa; font-size: 12px; }
#annotations-list .annotations-list-del { flex-shrink: 0; width: 24px; height: 24px; padding: 0; display: flex; align-items: center; justify-content: center; background: #333; border: 1px solid #444; border-radius: 6px; color: #aaa; font-size: 16px; line-height: 1; cursor: pointer; }
#annotations-list .annotations-list-del:hover { background: #444; color: #fff; }
/* Barre d'outils annotations sur la zone image */
#annotations-tools-overlay {
    position: absolute;
    left: 12px;
    top: 12px;
    z-index: 18;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
}
#annotations-tools-overlay.no-slide { display: none; }
#annotations-tools-overlay {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}
#annotations-tools-overlay #annotations-tools-toggle {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    border-radius: 10px;
    cursor: pointer;
}
#annotations-tools-overlay.collapsed .annotations-toolbar-panel {
    display: none;
}
#annotations-tools-overlay:not(.collapsed) .annotations-toolbar-panel {
    display: flex;
}
#annotations-tools-overlay #annotations-toolbar {
    margin-bottom: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}
#annotations-tools-overlay #annotations-toolbar .tool-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    border-radius: 10px;
    box-sizing: border-box;
}
#annotations-tools-overlay .annotations-toolbar-sep {
    width: 100%;
    margin: 8px 0;
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}
#annotations-tools-overlay .tool-options {
    display: flex;
    justify-content: center;
    padding: 4px 0;
}
#annotations-tools-overlay .tool-options input[type="color"] {
    width: 40px;
    height: 40px;
    padding: 2px;
    border-radius: 10px;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 0 1px var(--annotation-color, rgba(255, 255, 255, 0.2));
}
#annotations-tools-overlay .tool-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 0 0 1px var(--annotation-color, var(--accent));
}
#annotations-tools-overlay .tool-btn.primary:hover {
    filter: brightness(1.1);
}
#annotations-tools-overlay {
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(30, 30, 30, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Zones en haut de l'image (max 5, horizontal, fond réduit) */
#zones-viewer-overlay {
    position: absolute;
    left: 50%;
    top: 8px;
    transform: translateX(-50%);
    z-index: 17;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 8px;
    background: rgba(30, 30, 30, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.1);
    pointer-events: auto;
}
#zones-viewer-overlay.no-slide { display: none !important; }
#zones-viewer-overlay {
    min-height: 44px;
}
#zones-viewer-strip {
    display: flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
}
#zones-viewer-overlay .zone-strip-item {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid transparent;
    transition: border-color 0.15s, box-shadow 0.15s;
}
#zones-viewer-overlay .zone-strip-item:hover {
    border-color: #0d9488;
    box-shadow: 0 0 6px rgba(13, 148, 136, 0.4);
}
#zones-viewer-overlay .zone-strip-delete {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 14px;
    height: 14px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    border: none;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 2;
}
#zones-viewer-overlay .zone-strip-item:hover .zone-strip-delete {
    opacity: 1;
}
#zones-viewer-overlay .zone-strip-delete:hover {
    background: rgba(185, 28, 28, 0.9);
    color: #fff;
}
#zones-viewer-overlay .zone-strip-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
#zones-viewer-overlay .zone-save-server-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(13, 148, 136, 0.8);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
}
#zones-viewer-overlay .zone-save-server-btn:hover {
    background: #0d9488;
}
#zones-viewer-overlay .zone-add-btn {
    background: rgba(60, 60, 60, 0.9);
    color: #ccc;
}
#zones-viewer-overlay .zone-add-btn:hover {
    background: #444;
    color: #fff;
}
body.theme-light-neuro #zones-viewer-overlay {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}
body.theme-light-neuro #zones-viewer-overlay .zone-strip-item:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-soft);
}
body.theme-light-neuro #zones-viewer-overlay .zone-strip-delete {
    background: rgba(0, 0, 0, 0.6);
}
body.theme-light-neuro #zones-viewer-overlay .zone-strip-delete:hover {
    background: rgba(185, 28, 28, 0.9);
}
body.theme-light-neuro #zones-viewer-overlay .zone-save-server-btn {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
body.theme-light-neuro #zones-viewer-overlay .zone-save-server-btn:hover {
    background: var(--accent-hover);
}
body.theme-light-neuro #zones-viewer-overlay .zone-add-btn {
    background: var(--surface-2);
    color: var(--text-muted);
    border-color: var(--border);
}
body.theme-light-neuro #zones-viewer-overlay .zone-add-btn:hover {
    background: var(--surface);
    color: var(--text);
}

#annotations-overlay { position: absolute; left: 0; top: 0; right: 0; bottom: 0; z-index: 15; pointer-events: none; }
#annotations-overlay.drawing { pointer-events: auto; cursor: crosshair; }
#annotations-overlay svg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
#annotations-overlay svg .ann-label { font-size: 12px; font-family: -apple-system, sans-serif; fill: #fff; stroke: #000; stroke-width: 2px; paint-order: stroke fill; }

/* Notification toast (charte graphique) */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-family: -apple-system, sans-serif;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(30, 30, 30, 0.95);
    color: #eee;
    max-width: 320px;
    animation: toast-in 0.3s ease;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.toast-success {
    background: rgba(13, 148, 136, 0.92);
    border-color: rgba(255, 255, 255, 0.25);
    color: #fff;
}
.toast.toast-error {
    background: rgba(185, 28, 28, 0.92);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}
@keyframes toast-in {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}
body.theme-light-neuro .toast {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}
body.theme-light-neuro .toast.toast-success {
    background: var(--accent);
    border-color: var(--accent-hover);
    color: #fff;
}
body.theme-light-neuro .toast.toast-error {
    background: rgba(185, 28, 28, 0.9);
    border-color: rgba(185, 28, 28, 0.6);
    color: #fff;
}

.loading { color: #888; text-align: center; margin-top: 20px; }

.sidebar-title { margin: 0; font-size: 1.2em; color: var(--accent); }
.sidebar-subtitle { font-size: 11px; color: #666; }
.section-label { font-size: 12px; color: #888; margin-bottom: 8px; display: block; }
.meta-card-title { margin-top: 0; }
.annotations-storage-info { margin-top: 10px; font-size: 10px; color: #555; line-height: 1.4; }

/* ========== THÈME CLAIR NEUMORPHISME + MÉDICAL/SANTÉ ========== */
body.theme-light-neuro {
    --bg: #e6f7f5;
    --surface: rgba(255, 255, 255, 0.72);
    --surface-2: rgba(255, 255, 255, 0.5);
    --accent: #0d9488;
    --accent-hover: #0f766e;
    --accent-soft: rgba(13, 148, 136, 0.12);
    --text: #134e4a;
    --text-muted: #54716e;
    --border: rgba(13, 148, 136, 0.2);
    --shadow-soft: 6px 6px 12px rgba(163, 193, 190, 0.4);
    --shadow-inset: inset 3px 3px 6px rgba(163, 193, 190, 0.35);
    --shadow-out: -2px -2px 6px rgba(255, 255, 255, 0.9);
    --neuro-radius: 12px;
    --tool-size: 40px;
    background: var(--bg);
    color: var(--text);
}

body.theme-light-neuro #viewer-container {
    background: var(--surface);
}

body.theme-light-neuro #sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

body.theme-light-neuro .header {
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
}

body.theme-light-neuro .header h2 { color: var(--accent); }
body.theme-light-neuro .header p,
body.theme-light-neuro .section-label,
body.theme-light-neuro label[for] { color: var(--text-muted); }

body.theme-light-neuro .content { padding: 20px; }

body.theme-light-neuro select {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--neuro-radius);
    box-shadow: var(--shadow-inset);
}

body.theme-light-neuro #thumbnail-toggle button,
body.theme-light-neuro .zones-toolbar button:not(.active),
body.theme-light-neuro #annotations-actions button:not(.primary) {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--neuro-radius);
    box-shadow: var(--shadow-soft), var(--shadow-out);
}

body.theme-light-neuro #thumbnail-toggle button:hover,
body.theme-light-neuro .zones-toolbar button:hover:not(.active),
body.theme-light-neuro #annotations-actions button:hover:not(.primary) {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-inset);
}

body.theme-light-neuro #thumbnail-wrap {
    background: var(--surface-2);
    border-radius: var(--neuro-radius);
    box-shadow: var(--shadow-inset);
}
body.theme-light-neuro #thumbnail-wrap .thumb-label,
body.theme-light-neuro #thumbnail-wrap .thumb-error { color: var(--text-muted); }

body.theme-light-neuro #metadata-card,
body.theme-light-neuro .tile-source-card,
body.theme-light-neuro #layers-panel,
body.theme-light-neuro #zones-panel,
body.theme-light-neuro #annotations-panel {
    background: var(--surface-2);
    border-radius: var(--neuro-radius);
    padding: 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

body.theme-light-neuro #layers-panel h4,
body.theme-light-neuro #zones-panel h4,
body.theme-light-neuro #annotations-panel h4 {
    color: var(--accent);
}

body.theme-light-neuro .meta-item,
body.theme-light-neuro .meta-label { color: var(--text-muted); border-color: var(--border); }
body.theme-light-neuro .layer-category,
body.theme-light-neuro .overlay-check-row { color: var(--text-muted); }
body.theme-light-neuro #layers-panel input[type="range"] { accent-color: var(--accent); }
body.theme-light-neuro #layers-panel .overlay-pipeline-steps { background: var(--surface-2); color: var(--text-muted); border-left-color: var(--accent); }
body.theme-light-neuro #layers-panel .overlay-pipeline-steps strong { color: var(--text); }
body.theme-light-neuro #layers-panel .overlay-pipeline-steps em { color: var(--accent); }
body.theme-light-neuro .opacity-row span { color: var(--text-muted); }

/* Barre d'outils façon Blender : strip vertical d'icônes */
body.theme-light-neuro .tool-strip {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    background: var(--surface-2);
    border-radius: var(--neuro-radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-inset);
    width: fit-content;
}

body.theme-light-neuro #annotations-tools-overlay {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

body.theme-light-neuro #annotations-toolbar {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 6px;
    padding: 8px;
    background: var(--surface-2);
    border-radius: var(--neuro-radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-inset);
    width: fit-content;
    margin-bottom: 12px;
}

body.theme-light-neuro #annotations-tools-overlay #annotations-toolbar {
    flex-direction: column;
    margin-bottom: 0;
}
body.theme-light-neuro #annotations-tools-overlay #annotations-toolbar .tool-options {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    justify-content: center;
}
body.theme-light-neuro #annotations-tools-overlay .annotations-toolbar-sep {
    border-top-color: var(--border);
}
body.theme-light-neuro #annotations-tools-overlay #annotations-tools-toggle {
    width: var(--tool-size);
    height: var(--tool-size);
    min-width: var(--tool-size);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    box-shadow: var(--shadow-soft), var(--shadow-out);
}
body.theme-light-neuro #annotations-tools-overlay #annotations-tools-toggle:hover {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-inset);
}
body.theme-light-neuro #annotations-tools-overlay .tool-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: var(--shadow-soft);
}
body.theme-light-neuro #annotations-tools-overlay .tool-btn.primary:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-inset), 0 0 0 1px var(--annotation-color, var(--accent));
}
body.theme-light-neuro #annotations-tools-overlay #annotations-toolbar .tool-btn {
    box-shadow: var(--shadow-soft), var(--shadow-out), 0 0 0 1px var(--annotation-color, rgba(0,0,0,0.12));
}
body.theme-light-neuro #annotations-tools-overlay #annotations-toolbar .tool-btn:hover {
    box-shadow: var(--shadow-inset), 0 0 0 1px var(--annotation-color, rgba(0,0,0,0.12));
}
body.theme-light-neuro #annotations-tools-overlay #annotations-toolbar .tool-btn.active {
    box-shadow: var(--shadow-inset), 0 0 0 1px var(--annotation-color, rgba(0,0,0,0.12));
}
body.theme-light-neuro #annotations-tools-overlay .tool-btn.primary {
    box-shadow: var(--shadow-soft), 0 0 0 1px var(--annotation-color, var(--accent));
}
body.theme-light-neuro #annotations-tools-overlay .tool-options input[type="color"] {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    box-shadow: var(--shadow-inset), 0 0 0 1px var(--annotation-color, rgba(0,0,0,0.12));
}

body.theme-light-neuro #annotations-toolbar .tool-btn {
    width: var(--tool-size);
    height: var(--tool-size);
    min-width: var(--tool-size);
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    box-shadow: var(--shadow-soft), var(--shadow-out);
    cursor: pointer;
    transition: box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease;
}

body.theme-light-neuro #annotations-toolbar .tool-btn:hover {
    color: var(--text);
    background: var(--surface);
    box-shadow: var(--shadow-inset);
}

body.theme-light-neuro #annotations-toolbar .tool-btn.active {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: var(--shadow-inset);
}

body.theme-light-neuro #annotations-toolbar .tool-options {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

body.theme-light-neuro #annotations-toolbar .tool-options label { color: var(--text-muted); font-size: 11px; }
body.theme-light-neuro #annotations-toolbar .tool-options:has(input:only-child) label { display: none; }
body.theme-light-neuro #annotation-color {
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-inset);
}

body.theme-light-neuro .zones-toolbar {
    flex-direction: column;
    gap: 6px;
}

body.theme-light-neuro .zones-toolbar button {
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border-radius: 10px;
    box-shadow: var(--shadow-soft), var(--shadow-out);
}

body.theme-light-neuro .zones-toolbar button.active {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: var(--shadow-inset);
}

body.theme-light-neuro #annotations-actions button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: var(--shadow-soft);
}

body.theme-light-neuro #annotations-actions button.primary:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-inset);
}

body.theme-light-neuro #zones-list .zone-item {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-soft);
}

body.theme-light-neuro #zones-list .zone-item:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-inset);
}

body.theme-light-neuro #zones-list .zone-item .zone-label { color: var(--text); }
body.theme-light-neuro #zones-list .zone-item .zone-delete {
    background: var(--surface);
    color: var(--text-muted);
    border-radius: 8px;
}

body.theme-light-neuro #annotations-list,
body.theme-light-neuro .loading,
body.theme-light-neuro .annotations-storage-info { color: var(--text-muted); }
body.theme-light-neuro #annotations-list .annotations-list-row { border-bottom-color: var(--border); }
body.theme-light-neuro #annotations-list .annotations-list-row:hover { background: var(--surface-2); }
body.theme-light-neuro #annotations-list .annotations-list-label { color: var(--text-muted); }
body.theme-light-neuro #annotations-list .annotations-list-del { background: var(--surface-2); border-color: var(--border); color: var(--text-muted); box-shadow: var(--shadow-soft), 0 0 0 1px var(--border); }
body.theme-light-neuro #annotations-list .annotations-list-del:hover { background: var(--surface-3); color: var(--text); }

body.theme-light-neuro #scale-bar .bar { background: var(--accent); }
body.theme-light-neuro #scale-bar .label,
body.theme-light-neuro #zoom-level { color: var(--text); text-shadow: 0 0 2px rgba(255,255,255,0.8); }

body.theme-light-neuro .openseadragon-navigator {
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-soft) !important;
}

body.theme-light-neuro #selection-rect {
    border-color: var(--accent);
    background: var(--accent-soft);
}

/* Bouton de changement de thème */
#theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: inherit;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.85;
}
#theme-toggle:hover { opacity: 1; }

body.theme-light-neuro #theme-toggle {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--accent);
    box-shadow: var(--shadow-soft), var(--shadow-out);
}
body.theme-light-neuro #theme-toggle:hover {
    box-shadow: var(--shadow-inset);
}

body:not(.theme-light-neuro) #theme-toggle {
    background: #333;
    border: 1px solid #444;
    color: #aaa;
}
body:not(.theme-light-neuro) #theme-toggle:hover { background: #3a3a3a; color: #fff; }

/* ========== PAGES AUTH (login, register, set_password) — harmonisées viewer ========== */
.auth-page {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    box-sizing: border-box;
}
.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    box-sizing: border-box;
    border-radius: var(--neuro-radius, 12px);
    border: 1px solid var(--border, rgba(13, 148, 136, 0.2));
    background: var(--surface, rgba(255,255,255,0.72));
    box-shadow: var(--shadow-soft, 6px 6px 12px rgba(163, 193, 190, 0.4));
}
.auth-card .auth-logo {
    display: block;
    width: 100%;
    height: auto;
    max-height: 72px;
    object-fit: contain;
    object-position: center;
    margin: 0 0 1.25rem 0;
}
.auth-card h1 {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    color: var(--accent, #0d9488);
    font-weight: 600;
}
.auth-card .auth-subtitle {
    margin: 0 0 1.25rem 0;
    font-size: 0.9rem;
    color: var(--text-muted, #54716e);
    line-height: 1.4;
}
.auth-form label {
    display: block;
    margin-top: 1rem;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted, #54716e);
}
.auth-form label:first-of-type { margin-top: 0; }
.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="text"],
.auth-form select {
    width: 100%;
    padding: 10px 12px;
    box-sizing: border-box;
    font-size: 1rem;
    border-radius: var(--neuro-radius, 12px);
    border: 1px solid var(--border, rgba(13, 148, 136, 0.2));
    background: var(--surface-2, rgba(255,255,255,0.5));
    color: var(--text, #134e4a);
    outline: none;
}
.auth-form input::placeholder { color: var(--text-muted); opacity: 0.8; }
.auth-form input:focus,
.auth-form select:focus {
    border-color: var(--accent, #0d9488);
}
.auth-form .checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.auth-form .checkbox-row input { width: auto; cursor: pointer; }
.auth-form .actions { margin-top: 1.5rem; }
.auth-form button[type="submit"] {
    width: 100%;
    padding: 12px 18px;
    font-size: 1rem;
    font-weight: 500;
    border-radius: var(--neuro-radius, 12px);
    border: 1px solid var(--accent, #0d9488);
    background: var(--accent, #0d9488);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s, filter 0.15s;
}
.auth-form button[type="submit"]:hover {
    background: var(--accent-hover, #0f766e);
    border-color: var(--accent-hover, #0f766e);
    filter: brightness(1.02);
}
.auth-msg {
    margin-top: 1rem;
    padding: 12px 14px;
    border-radius: var(--neuro-radius, 12px);
    font-size: 0.9rem;
    display: none;
}
.auth-msg.error {
    background: rgba(185, 28, 28, 0.1);
    color: #b91c1c;
    border: 1px solid rgba(185, 28, 28, 0.3);
}
.auth-msg.ok {
    background: var(--accent-soft, rgba(13, 148, 136, 0.12));
    color: var(--accent-hover, #0f766e);
    border: 1px solid var(--border);
}
.auth-links {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border, rgba(13, 148, 136, 0.2));
}
.auth-links p { margin: 0.5rem 0 0 0; }
.auth-links a {
    color: var(--accent, #0d9488);
    text-decoration: none;
    font-size: 0.9rem;
}
.auth-links a:hover { text-decoration: underline; }
body.theme-light-neuro .auth-page { background: var(--bg); color: var(--text); }
body.theme-light-neuro .auth-card {
    background: var(--surface);
    border-color: var(--border);
    box-shadow: var(--shadow-soft);
}
body:not(.theme-light-neuro) .auth-page { background: var(--bg-dark, #121212); color: #e8e8e8; }
body:not(.theme-light-neuro) .auth-card {
    background: var(--panel-bg, #1e1e1e);
    border-color: #333;
    box-shadow: 2px 2px 12px rgba(0,0,0,0.3);
}
body:not(.theme-light-neuro) .auth-form input,
body:not(.theme-light-neuro) .auth-form select {
    background: #333;
    border-color: #444;
    color: #fff;
}
body:not(.theme-light-neuro) .auth-links a { color: var(--accent, #007aff); }
