:root {
    --syno-blue: #0a87d6;
    --syno-pink: #ffb6c1;
    --bg-color: #e6f5fc;
    --text-color: #172b4d;
    --card-bg: #ffffff;
    --gap: 10px;
    --width: 400px;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--body-bg-color, #b8860b80);
    color: var(--text-color);
    height: 100vh;
    height: 100dvh;
    /* Dynamic viewport height for mobile browsers */
    display: flex;
    flex-direction: column;
    background-image: var(--body-bg-image);
    background-repeat: repeat;
    overflow: hidden;
    /* Avoid double scrollbars and body-level scrolling */
}

/* Toolbar */
.toolbar {
    background-color: transparent;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    z-index: 100;
    flex-wrap: wrap;
    /* Allow wrapping on small screens */
}

.toolbar-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    color: var(--text-color);
}

.toolbar-btn:hover {
    background-color: #e1e4e8;
}

.toolbar-spacer_large {
    flex-grow: 10;
}

.toolbar-spacer {
    flex-grow: 1;
}

.toolbar-btnx {
    width: 40px;
    height: 40px;
}

.tooltip {
    position: relative;
}

.tooltip .tooltiptext {
    visibility: hidden;
    display: inline-block;
    background-color: #fbfcc7;
    color: #000;
    text-align: center;
    left: 0%;
    border-radius: 6px;
    padding: 5px 5px;
    position: absolute;
    top: -10px;
    width: max-content;
    font-size: 15px;
    line-height: 15px;
    height: max-content;
    z-index: 1;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    transition-delay: 1.0s;
}

/* Vignette Grid */
.vignette-container {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
    display: grid;
    align-content: flex-start;
    gap: var(--gap);
    justify-content: center;
    grid-template-columns: repeat(auto-fill, var(--width));
    background-color: transparent;
}

.vignette {
    position: relative;
    background-color: var(--card-bg);
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.vignette:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.vignette.large {
    width: var(--width);
    max-width: 100%;
    height: 300px;
}

.vignette.small {
    width: var(--width);
    max-width: 100%;
    height: 150px;
}

.vignette.dragging {
    /* Reduce transparency when dragging so preview remains more visible */
    opacity: 0.92;
    transform: scale(0.97);
    outline: 2px dashed var(--syno-blue);
    outline-offset: -2px;
}

.vignette.drag-over {
    box-shadow: 0 0 15px var(--syno-blue);
    outline: 2px solid var(--syno-blue);
    outline-offset: -2px;
}

/* Vignette Content */
.v-image {
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    background-size: cover;
    /* Or contain, depending on user pref "redimensionnée à la taille" */
    background-position: center;
    background-repeat: no-repeat;
}

/* Skeleton Loader for Images */
.v-image:not(.loaded) {
    background: linear-gradient(90deg,
            #f0f0f0 0%,
            #e0e0e0 20%,
            #f0f0f0 40%,
            #f0f0f0 100%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes skeleton-pulse {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Top Bar (Overlay) */
.v-top-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 32px;
    background-color: var(--syno-blue);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 5px;
    box-sizing: border-box;
    opacity: 0;
    transition: opacity 0.2s;
}

.vignette:hover .v-top-bar {
    opacity: 1;
}

.v-actions-left {
    display: flex;
    gap: 5px;
}

.v-icon-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 5px;
}

.v-icon-btn:hover {
    opacity: 0.8;
}

/* Bottom Bar (Label) */
.v-bottom-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 5px 10px;
    background-color: var(--syno-pink);
    color: #333;
    font-size: 14px;
    font-weight: 500;
    box-sizing: border-box;
    opacity: 0;
    transition: opacity 0.2s;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vignette:hover .v-bottom-bar {
    opacity: 1;
}

/* Login Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    width: 350px;
    overflow: hidden;
    animation: slideIn 0.3s ease;
}

.modal-header {
    background-color: var(--syno-blue);
    color: white;
    padding: 15px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close {
    cursor: pointer;
    font-size: 18px;
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
}

.form-control {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

.form-control:focus {
    border-color: var(--syno-blue);
    outline: none;
}

.btn-primary {
    background-color: var(--syno-blue);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.btn-primary:hover {
    filter: brightness(0.9);
}

@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Force show bars for shortcut */
.show-all-bars .v-top-bar,
.show-all-bars .v-bottom-bar {
    opacity: 1 !important;
}

/* Custom Combobox */
.combobox-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

#combobox {
    width: 300px;
}

#edit-cat {
    /* Ensure input takes available space but leaves room for button if needed */
    flex: 1;
    padding-right: 30px;
    /* Space for arrow inside visual container */
}

.combo-arrow {
    position: absolute;
    right: 1px;
    top: 1px;
    bottom: 1px;
    width: 30px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 12px;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}

.combo-arrow:hover {
    background-color: #f0f0f0;
}

.combo-options {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 2000;
    list-style: none;
    padding: 0;
    margin: 0;
}

.combo-options li {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
}

.combo-options li:hover {
    background-color: var(--syno-blue);
    color: white;
}

/* Custom Fields */
.custom-field-item {
    border-bottom: 1px dashed #eee;
}

.custom-field-item:last-child {
    border-bottom: none;
}

.custom-field-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--syno-blue);
    /* Highlight custom field names slightly */
}

.btn-remove-field {
    color: #cc0000;
    cursor: pointer;
    font-size: 14px;
    padding: 5px;
}

.btn-remove-field:hover {
    text-decoration: underline;
}

#drop-zone {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, border-color 0.2s;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
}

/* Texture Grid */
.texture-grid {
    user-select: none;
}

.texture-item {
    cursor: pointer;
    text-align: center;
    border: 2px solid transparent;
    border-radius: 4px;
    padding: 5px;
    transition: all 0.2s;
}

.texture-item:hover {
    background: #f0f0f0;
}

.texture-item.selected {
    border-color: var(--syno-blue);
    background: #eef7ff;
}

.texture-preview {
    width: 100%;
    aspect-ratio: 1;
    background-size: cover;
    background-position: center;
    background-repeat: repeat;
    border: 1px solid #ddd;
    border-radius: 2px;
    margin-bottom: 5px;
}

.texture-preview.none {
    background: #eee;
    position: relative;
}

.texture-preview.none::after {
    content: "X";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #999;
    font-weight: bold;
}

.texture-item span {
    font-size: 11px;
    color: #555;
    display: block;
}

/* Notes Display */
.v-note-content {
    width: 100%;
    height: 100%;
    resize: none;
    border: none;
    padding: 2px 1px;
    /* Leave space for top/bottom bars */
    box-sizing: border-box;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    background-color: #fffbeb;
    /* Light yellow for notes */
    color: #333;
    line-height: 1.4;
    outline: none;
}

/* Responsive: Hide extraneous buttons on small screens */
@media (max-width: 870px) {
    #btn-settings {
        display: none !important;
    }
}

@media (max-width: 810px) {
    #btn-gmail {
        display: none !important;
    }
}

@media (max-width: 755px) {
    #btn-smail {
        display: none !important;
    }
}

@media (max-width: 700px) {
    #btn-photo {
        display: none !important;
    }
}

@media (max-width: 645px) {
    #btn-files {
        display: none !important;
    }
}

@media (max-width: 590px) {
    #btn-size {
        display: none !important;
    }
}

@media (max-width: 540px) {
    #combobox {
        width: 200px;
    }
}

@media (max-width: 496px) {
    #btn-genpass {
        display: none !important;
    }
}

@media (max-width: 496px) {
    #btn-genpass {
        display: none !important;
    }
}

@media (max-width: 400px) {
    #combobox {
        width: 170px;
    }

    .hide-on-small {
        display: none !important;
    }
}

/* Mobile PWA Optimizations */
@media (max-width: 10px) {
    .ztoolbar {
        padding: 10px;
        gap: 10px;
        overflow-x: auto;
        /* Allow horizontal scroll if items overflow */
        flex-wrap: nowrap;
        /* Keep items in one row if preferred, or wrap */
        -webkit-overflow-scrolling: touch;
    }

    .toolbar-btnx {
        width: 44px;
        /* Minimum touch target size */
        height: 44px;
        flex-shrink: 0;
    }

    #zcombobox {
        width: 100%;
        /* Full width search on mobile */
        min-width: 150px;
    }

    .zvignette-container {
        padding: 10px;
        gap: 10px;
        /* Mobile grid: typically 2 columns or 1 column depending on width */
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .zvignette.large,
    .zvignette.small {
        width: 100%;
        /* Let grid control width */
        height: auto;
        aspect-ratio: 1;
        /* Square vignettes on mobile? or keep height? */
        min-height: 150px;
    }

    .zform-control {
        font-size: 16px;
        /* Prevent iOS zoom */
        padding: 10px;
        height: 44px;
        /* Touch target */
        box-sizing: border-box;
    }

    .zmodal-box {
        width: 90%;
        max-width: 350px;
    }

    .tooltip .tooltiptext {
        display: none;
        /* Hide tooltips on touch devices as they get stuck */
    }
}