@font-face {
    font-family: "Inter";
    src: url("../assets/fonts/Inter-VariableFont_opsz,wght.ttf") format("truetype");
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
}

:root {
    --primary-font: "Inter", sans-serif;
    --background-color: #ffffff;
    --text-color: #222222;
    --accent-color: #666666;
    --line-color: rgba(34, 34, 34, 0.34);
    --page-gutter: 3rem;
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--primary-font);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.4;
    min-height: 100vh;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    font-optical-sizing: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100%;
    margin: 0 auto;
    padding: 0;
    overflow: hidden;
}

input[type="file"] {
    position: absolute;
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    z-index: -1;
}

/* Saved-colour home */
.colour-library {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 3rem var(--page-gutter) 0;
    overflow: hidden;
    background: #ffffff;
    color: #171717;
    text-transform: none;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.55s var(--ease-out), transform 0.55s var(--ease-out), visibility 0s linear 0s;
}

body.has-image .colour-library,
body.split-view-active .colour-library,
body.is-dragging .colour-library {
    opacity: 0;
    transform: translateY(-8px);
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.55s var(--ease-out), transform 0.55s var(--ease-out), visibility 0s linear 0.55s;
}

body.has-image .colour-library .library-content,
body.split-view-active .colour-library .library-content,
body.is-dragging .colour-library .library-content {
    pointer-events: none;
}

.library-heading {
    flex: 0 0 auto;
}

.library-title {
    font-family: var(--primary-font);
    font-size: 4.25rem;
    font-weight: 400;
    font-optical-sizing: auto;
    line-height: 0.95;
    letter-spacing: -0.18rem;
    text-transform: none;
    opacity: 0;
    transform: translateY(18px);
}

.library-intro {
    display: grid;
    max-height: 7rem;
    margin-top: 1.55rem;
    padding-bottom: 0.14em;
    overflow: hidden;
    font-size: 1.3rem;
    font-weight: 400;
    line-height: 1.12;
    letter-spacing: -0.035em;
    transition: max-height 0.65s var(--ease-out), margin 0.65s var(--ease-out), padding-bottom 0.42s ease, opacity 0.42s ease, transform 0.65s var(--ease-out);
}

.library-intro-line {
    display: flex;
    align-items: center;
    min-width: 0;
    opacity: 0;
    transform: translateY(12px);
}

.library-progress-line {
    font-variant-numeric: tabular-nums;
}

.library-status-dex {
    display: block;
    width: 0.78em;
    height: 0.78em;
    margin: 0 0.42em;
    flex: 0 0 auto;
    object-fit: contain;
}

body.home-mounted .library-title {
    animation: library-reveal 0.85s var(--ease-out) 0.08s forwards;
}

body.home-mounted .library-intro-line:nth-child(1) {
    animation: library-reveal 0.65s var(--ease-out) 0.38s forwards;
}

body.home-mounted .library-intro-line:nth-child(2) {
    animation: library-reveal 0.65s var(--ease-out) 0.5s forwards;
}

body.home-mounted .library-intro-line:nth-child(3) {
    animation: library-reveal 0.65s var(--ease-out) 0.62s forwards;
}

@keyframes library-reveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.library-content {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    margin-top: 2.25rem;
    opacity: 0;
    transform: translateY(18px);
    pointer-events: none;
    transition: opacity 0.65s ease, transform 0.75s var(--ease-out);
}

body.library-ready .library-intro {
    max-height: 0;
    margin-top: 0;
    padding-bottom: 0;
    opacity: 0;
    transform: translateY(-10px);
}

body.library-ready .library-content {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.library-view-bar {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    margin-bottom: 0.65rem;
    color: #8a8a8a;
    font-size: 0.64rem;
    font-weight: 400;
    letter-spacing: 0.2px;
    line-height: 1.2;
}

.library-tabs {
    display: flex;
    align-items: center;
    gap: 1.15rem;
}

.library-tab {
    appearance: none;
    padding: 0;
    border: 0;
    background: transparent;
    color: #9a9a9a;
    font: inherit;
    letter-spacing: inherit;
    text-transform: none;
    cursor: pointer;
    transition: color 0.25s ease;
}

.library-tab:hover,
.library-tab:focus-visible,
.library-tab.is-active {
    color: #222222;
    outline: none;
}

.library-view-panel[hidden] {
    display: none;
}

.library-rule {
    width: 100%;
    flex: 0 0 auto;
    border-top: 0.5px solid var(--line-color);
}

.library-view-panel {
    flex: 1 1 auto;
    min-height: 0;
}

.library-panel {
    display: grid;
    grid-template-areas: 'library-stack';
    overflow: hidden;
}

.saved-colours {
    display: block;
    grid-area: library-stack;
    width: 100%;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0 0 4.5rem;
    scrollbar-width: none;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.saved-colours::-webkit-scrollbar {
    display: none;
}

.explore-panel {
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0.75rem 0 4.5rem;
    scrollbar-width: none;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.explore-panel::-webkit-scrollbar {
    display: none;
}

.explore-grid {
    display: block;
    width: 100%;
}

.explore-row {
    display: grid;
    grid-template-columns: repeat(var(--explore-columns, 12), minmax(0, 1fr));
    width: 100%;
    height: clamp(112px, 9vw, 132px);
}

.explore-swatch {
    position: relative;
    grid-column: span var(--explore-span, 2);
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: var(--explore-colour);
    color: var(--explore-text);
    box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.08);
    font-family: var(--primary-font);
    opacity: 0;
    cursor: pointer;
    translate: 0 8px;
    scale: 1;
    animation: explore-swatch-in 0.48s var(--ease-out) forwards;
    animation-delay: calc(var(--explore-index, 0) * 22ms);
    transition: scale 0.2s ease;
}

.explore-spacer {
    grid-column: span var(--explore-span, 1);
    height: 100%;
    min-width: 0;
    min-height: 0;
    pointer-events: none;
}

@keyframes explore-swatch-in {
    to {
        opacity: 1;
        translate: 0 0;
    }
}

.explore-swatch::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.12);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.explore-swatch:hover::after,
.explore-swatch:focus-visible::after {
    opacity: 1;
}

.explore-swatch:hover,
.explore-swatch:focus-visible {
    z-index: 2;
    scale: 0.9;
}

.explore-swatch:focus-visible {
    outline: 1px solid currentColor;
    outline-offset: -3px;
}

.explore-swatch-details {
    position: absolute;
    right: 0.48rem;
    bottom: 0.45rem;
    left: 0.48rem;
    z-index: 1;
    display: grid;
    gap: 0.08rem;
    overflow: hidden;
    font-size: 0.46rem;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.3px;
    line-height: 1.25;
    text-align: left;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
    transition: transform 0.35s var(--ease-out);
}

.explore-swatch:hover .explore-swatch-details,
.explore-swatch:focus-visible .explore-swatch-details {
    transform: translateY(-3px);
}

.saved-image-group {
    width: 100%;
    padding: 0.85rem 0 1.15rem;
}

.saved-image-group + .saved-image-group {
    padding-top: 1rem;
}

.saved-image-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    color: #777777;
    font-size: 0.64rem;
    font-weight: 400;
    letter-spacing: 0.2px;
    line-height: 1.2;
}

.saved-image-name {
    appearance: none;
    min-width: 0;
    overflow: hidden;
    padding-right: 1rem;
    border: 0;
    background: transparent;
    color: #222222;
    font: inherit;
    letter-spacing: inherit;
    text-align: left;
    text-overflow: ellipsis;
    text-transform: inherit;
    white-space: nowrap;
    cursor: text;
    transition: color 0.25s ease;
    -webkit-user-select: none;
    user-select: none;
}

.combination-title {
    margin: 0;
    color: #222222;
    font: inherit;
    letter-spacing: 0;
}

.saved-image-name:hover,
.saved-image-name:focus-visible,
.saved-image-name.is-placeholder {
    color: #9a9a9a;
    outline: none;
}

.saved-image-title-input {
    width: min(32rem, 75%);
    min-width: 0;
    padding: 0 1rem 0 0;
    border: 0;
    border-radius: 0;
    outline: 0;
    background: transparent;
    color: #222222;
    font: inherit;
    letter-spacing: inherit;
    line-height: inherit;
    text-transform: inherit;
}

.saved-image-title-input::placeholder {
    color: #a5a5a5;
    opacity: 1;
}

.saved-image-count {
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
}

.saved-image-divider {
    width: 100%;
    margin-top: 0.55rem;
    border-top: 0.5px solid var(--line-color);
}

.saved-image-colours {
    display: flex;
    align-items: flex-start;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    margin-top: 0.75rem;
}

.saved-image-colours::-webkit-scrollbar {
    display: none;
}

.saved-colour {
    position: relative;
    flex: 0 0 104px;
    width: 104px;
    height: 104px;
    overflow: hidden;
    background: var(--saved-colour);
    color: var(--saved-colour-text);
    box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.08);
    opacity: 0;
    translate: 0 12px;
    scale: 1;
    scroll-snap-align: start;
    animation: saved-colour-reveal 0.55s var(--ease-out) forwards;
    animation-delay: calc(var(--saved-index, 0) * 45ms);
    transition: scale 0.2s ease;
}

@keyframes saved-colour-reveal {
    to {
        opacity: 1;
        translate: 0 0;
    }
}

.saved-colour:hover,
.saved-colour:focus-within {
    z-index: 2;
    scale: 0.9;
}

.saved-colour-open {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0.5rem;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.saved-colour-details {
    position: absolute;
    right: 0.48rem;
    bottom: 0.45rem;
    left: 0.48rem;
    display: grid;
    gap: 0.08rem;
    font-size: 0.46rem;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.3px;
    line-height: 1.25;
    text-transform: uppercase;
    transition: transform 0.35s var(--ease-out);
}

.saved-colour-remove {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    z-index: 2;
    width: 1.25rem;
    height: 1.25rem;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.72);
    color: #171717;
    opacity: 0;
    cursor: pointer;
    transform: scale(0.88);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    transition: opacity 0.25s ease, transform 0.35s var(--ease-out);
}

.saved-colour-remove::before,
.saved-colour-remove::after,
.library-info-close::before,
.library-info-close::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 7px;
    height: 1px;
    border-radius: 1px;
    background: currentColor;
}

.saved-colour-remove::before,
.library-info-close::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.saved-colour-remove::after,
.library-info-close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.saved-colour:hover .saved-colour-details,
.saved-colour:focus-within .saved-colour-details {
    transform: translateY(-3px);
}

.saved-colour:hover .saved-colour-remove,
.saved-colour:focus-within .saved-colour-remove {
    opacity: 1;
    transform: scale(1);
}

.saved-colour-remove:focus-visible,
.saved-colour-open:focus-visible,
.drop-note:focus-visible,
.return-home:focus-visible,
.library-info-button:focus-visible,
.library-info-close:focus-visible {
    outline: 1px solid currentColor;
    outline-offset: -3px;
}

.library-empty {
    grid-area: library-stack;
    align-self: start;
    margin-top: 1rem;
    color: #888888;
    font-size: 0.62rem;
    letter-spacing: 0.2px;
}

.library-empty[hidden] {
    display: none;
}

.drop-note {
    position: fixed;
    left: var(--page-gutter);
    bottom: calc(2.25rem + env(safe-area-inset-bottom));
    z-index: 4;
    color: #777777;
    font-size: 0.62rem;
    font-weight: 400;
    letter-spacing: 0.2px;
    text-transform: none;
    cursor: pointer;
    transition: color 0.25s ease;
    -webkit-user-select: none;
    user-select: none;
}

.drop-note:hover {
    color: #171717;
}

.drop-note-mobile {
    display: none;
}

.library-info-button {
    position: fixed;
    right: var(--page-gutter);
    bottom: calc(2.25rem + env(safe-area-inset-bottom));
    z-index: 4;
    display: grid;
    width: 1.45rem;
    height: 1.45rem;
    place-items: center;
    padding: 0;
    border: 0.5px solid rgba(34, 34, 34, 0.28);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.72);
    color: #777777;
    font-family: var(--primary-font);
    font-size: 0.62rem;
    font-weight: 500;
    line-height: 1;
    text-transform: none;
    cursor: pointer;
    transition: border-color 0.25s ease, color 0.25s ease, background-color 0.25s ease;
}

.library-info-button:hover {
    border-color: rgba(34, 34, 34, 0.52);
    background: #f4f4f4;
    color: #171717;
}

.library-info-dialog {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: auto;
    width: min(32rem, 100%);
    max-width: none;
    max-height: min(80vh, 46rem);
    margin: 0;
    padding: 0;
    overflow: auto;
    border: 0;
    background: transparent;
    color: #222222;
    text-transform: none;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.library-info-dialog::backdrop {
    background: rgba(255, 255, 255, 0.22);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

.library-info-dialog[open] {
    animation: info-dialog-in 0.52s var(--ease-out) both;
}

.library-info-dialog.is-closing {
    animation: info-dialog-out 0.3s ease both;
}

@keyframes info-dialog-in {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
}

@keyframes info-dialog-out {
    to {
        opacity: 0;
        transform: translateY(100%);
    }
}

.library-info-panel {
    position: relative;
    min-height: 100%;
    padding: 1.25rem 3.25rem calc(1.4rem + env(safe-area-inset-bottom)) 1.25rem;
    border-top: 0.5px solid rgba(34, 34, 34, 0.14);
    border-left: 0.5px solid rgba(34, 34, 34, 0.14);
    border-radius: 0;
    background: rgba(248, 248, 248, 0.96);
    box-shadow: -12px -12px 45px rgba(0, 0, 0, 0.05);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
}

.library-info-panel h2 {
    margin-bottom: 0.7rem;
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0;
    line-height: 1.25;
}

.library-info-panel p {
    color: #222222;
    font-size: 1.3rem;
    font-weight: 400;
    letter-spacing: -0.035em;
    line-height: 1.12;
}

.library-info-panel p + p {
    margin-top: 1rem;
}

.library-info-close {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    width: 1.3rem;
    height: 1.3rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #777777;
    cursor: pointer;
    transition: color 0.25s ease, background-color 0.25s ease;
}

.library-info-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #171717;
}

.return-home {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 150;
    display: grid;
    width: 2rem;
    height: 2rem;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.74);
    color: #222222;
    font-family: var(--primary-font);
    font-size: 1rem;
    font-weight: 400;
    line-height: 1;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    cursor: pointer;
    transform: translateY(-4px);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: opacity 0.3s ease, transform 0.4s var(--ease-out), background-color 0.25s ease, visibility 0s linear 0.3s;
    -webkit-user-select: none;
    user-select: none;
}

body.has-image:not(.split-view-active):not(.is-returning-home) .return-home {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
    transition-delay: 0.12s, 0.12s, 0s, 0s;
}

.return-home:hover {
    background: rgba(255, 255, 255, 0.94);
}

.drop-target {
    position: fixed;
    inset: 0;
    z-index: 220;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.86);
    color: #171717;
    font-size: 0.68rem;
    font-weight: 400;
    letter-spacing: 0.3px;
    text-transform: none;
    opacity: 0;
    pointer-events: none;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: opacity 0.45s var(--ease-out);
}

body.is-dragging .drop-target {
    opacity: 1;
}

main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    overflow: visible;
    margin-top: 0;
    height: calc(var(--vh, 100vh) - 100px);
    min-height: 300px;
    margin-bottom: 100px;
    opacity: 1;
    transition: opacity 0.55s var(--ease-out), transform 0.55s var(--ease-out);
}

body.is-empty main {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
}

body.is-dragging.has-image main,
body.is-dragging.has-image footer {
    opacity: 0.12;
    transform: scale(0.995);
}

body.is-returning-home main,
body.is-returning-home footer {
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
}

@media (min-width: 769px) {
    main {
        height: calc(var(--vh, 100vh) - 100px);
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .container {
        margin: 0 auto;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        height: 100%;
    }
}

@media (max-width: 768px) {
    :root {
        --page-gutter: 1rem;
    }

    .colour-library {
        padding-top: 1.25rem;
        padding-bottom: 0;
    }

    .library-title {
        font-size: 3rem;
        letter-spacing: -0.12rem;
    }

    .library-intro {
        max-height: 6rem;
        margin-top: 1.15rem;
        font-size: 1.05rem;
        line-height: 1.12;
    }

    .library-content {
        margin-top: 1.4rem;
    }

    .library-view-bar {
        margin-bottom: 0.55rem;
        font-size: 0.58rem;
    }

    .library-tabs {
        gap: 1rem;
    }

    .saved-colours {
        padding-bottom: 3.75rem;
    }

    .explore-panel {
        padding-top: 0.65rem;
        padding-bottom: 3.75rem;
    }

    .explore-grid {
        width: 100%;
    }

    .explore-row {
        height: 108px;
    }

    .explore-swatch-details {
        right: 0.4rem;
        bottom: 0.38rem;
        left: 0.4rem;
        font-size: 0.42rem;
    }

    .explore-swatch.is-compact .explore-swatch-details span:last-child {
        display: none;
    }

    .saved-image-group {
        padding: 0.65rem 0 0.85rem;
    }

    .saved-image-heading {
        margin-bottom: 0;
        font-size: 0.58rem;
    }

    .saved-image-divider {
        margin-top: 0.48rem;
    }

    .saved-image-colours {
        margin-top: 0.65rem;
    }

    .saved-colour {
        flex-basis: 88px;
        width: 88px;
        height: 88px;
    }

    .saved-colour-open {
        padding: 0.4rem;
    }

    .saved-colour-details {
        right: 0.4rem;
        bottom: 0.38rem;
        left: 0.4rem;
        font-size: 0.42rem;
    }

    .saved-colour-remove {
        top: 0.28rem;
        right: 0.28rem;
        width: 1.1rem;
        height: 1.1rem;
        opacity: 1;
        transform: scale(1);
    }

    .drop-note {
        left: var(--page-gutter);
        bottom: calc(1.25rem + env(safe-area-inset-bottom));
    }

    .library-info-button {
        right: var(--page-gutter);
        bottom: calc(1.25rem + env(safe-area-inset-bottom));
    }

    .library-info-dialog {
        width: 100%;
        max-height: 86vh;
    }

    .library-info-panel {
        padding: 1.1rem 3rem calc(1.2rem + env(safe-area-inset-bottom)) 1rem;
        border-left: 0;
    }

    .library-info-panel h2 {
        margin-bottom: 0.65rem;
        font-size: 0.62rem;
    }

    .library-info-panel p {
        font-size: 1.05rem;
        line-height: 1.12;
    }

    .return-home {
        top: 0.75rem;
        left: 0.75rem;
    }

    .drop-note-desktop {
        display: none;
    }

    .drop-note-mobile {
        display: inline;
    }

    main {
        align-items: center;
        justify-content: center;
        height: calc(var(--vh, 100vh) - 100px);
        max-height: none;
        min-height: 200px;
        padding: 0.75rem;
        overflow-y: hidden;
        margin-bottom: 100px;
    }
    
    .image-container {
        max-height: calc(var(--vh, 100vh) - 100px - 1.5rem);
        margin-top: 0;
    }
    
    footer {
        height: 100px; /* Fixed height for footer on mobile */
    }
}

.image-container {
    position: relative;
    overflow: visible;
    background-color: transparent;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: crosshair;
    transition: width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), height 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: calc(var(--vh, 100vh) - 100px - 2rem);
}

.image-container,
#color-dots-container,
.color-dot,
.palette-section h3,
.palette-header-icons,
.add-variant,
.download-palette,
.saved-colour-remove {
    -webkit-user-select: none;
    user-select: none;
}

body.is-empty footer {
    height: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

#uploaded-image {
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

#color-dots-container {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: all;
}

.color-dot {
    --plus-offset-y: 0px;
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: grab;
    pointer-events: auto;
    transform: translate(-50%, -50%);
    z-index: 10;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease;
}

.color-dot::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    color: #222;
    display: block;
    width: 10px;
    height: 1.5px;
    background-color: #222;
    border-radius: 1px;
    transform-origin: 50% 50%;
    transition: transform 0.15s ease;
    transform: translate(-50%, calc(-50% + var(--plus-offset-y))) rotate(0deg);
}

.color-dot::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    display: block;
    width: 10px;
    height: 1.5px;
    background-color: #222;
    border-radius: 1px;
    transform-origin: 50% 50%;
    transition: transform 0.15s ease;
    transform: translate(-50%, calc(-50% + var(--plus-offset-y))) rotate(90deg);
}

.color-dot:hover::before {
    transform: translate(-50%, calc(-50% + var(--plus-offset-y))) rotate(90deg);
}

.color-dot:hover::after {
    transform: translate(-50%, calc(-50% + var(--plus-offset-y))) rotate(180deg);
}

/* Safari-specific glyph baseline correction for the plus icon */
.is-safari .color-dot {
    --plus-offset-y: 0.5px;
}

.color-dot.dragging {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
    z-index: 20;
}

.color-dot.highlight {
    transform: translate(-50%, -50%) scale(1.2);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.8), 0 0 8px rgba(0, 0, 0, 0.3);
    z-index: 20;
}

.color-dot.dimmed {
    opacity: 0.3;
}

.color-dot.selected {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.12);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
    z-index: 25;
}

.color-dot.pulse {
    animation: pulse 1s ease-in-out;
    z-index: 30;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.3);
        box-shadow: 0 0 15px rgba(255, 255, 255, 0.8), 0 0 8px rgba(0, 0, 0, 0.3);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
    }
}

footer {
    padding: 0;
    position: fixed; /* Change from sticky to fixed */
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--background-color);
    z-index: 100;
    transition: opacity 0.45s var(--ease-out), transform 0.45s var(--ease-out);
}

.color-swatches {
    display: flex;
    gap: 0;
    overflow-x: auto;
    padding: 0;
    scrollbar-width: none;
    width: 100%;
    height: 100px; /* Fixed height instead of min-height */
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
}

.color-swatches::-webkit-scrollbar {
    display: none;
}

.color-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
    margin: 0;
    cursor: pointer;
    transition: transform 0.2s ease;
    position: relative;
}

.color-swatch:hover {
    transform: translateY(-3px);
    z-index: 10;
}

.color-swatch:active {
    transform: translateY(-1px);
}

.swatch-preview {
    width: 100px;
    height: 100px;
    border-radius: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    box-shadow: none;
    transition: all 0.2s ease;
}

.color-swatch:hover .swatch-preview {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.swatch-details {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
    text-align: left;
    padding: 0.7rem;
    background-color: transparent;
}

.swatch-hex, .swatch-rgb {
    font-size: 0.55rem;
    font-weight: 400;
    margin-bottom: 0.1rem;
    letter-spacing: 0.3px;
}

/* Split view for color palette */
.split-view {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: calc(var(--vh, 100vh) - 100px);
    z-index: 160;
    background-color: var(--background-color);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

body.is-empty .split-view {
    height: var(--vh, 100vh);
}

.split-view.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

/* Hide the main content when split view is active */
.split-view.active + main .image-container,
.split-view.active ~ main .image-container {
    opacity: 0;
    visibility: hidden;
}

.split-view-left {
    width: 60%;
    height: 100%;
    overflow: hidden;
    border-right: none;
    padding: 1rem;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.split-view-left .image-container {
    position: relative;
    height: auto;
    width: auto;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
}

.split-view-left img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.library-colour-preview {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--library-preview-colour);
    color: var(--library-preview-text);
}

.library-colour-preview-details {
    position: absolute;
    right: 0.85rem;
    bottom: 0.8rem;
    left: 0.85rem;
    display: grid;
    gap: 0.08rem;
    font-size: 0.58rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.3px;
    line-height: 1.25;
}

.split-view-right {
    width: 40%;
    height: 100%;
    overflow-y: auto;
    padding: 1rem 1rem 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 0;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.split-view.active .split-view-left,
.split-view.active .split-view-right {
    opacity: 1;
    transform: translateX(0);
}

.is-wheel-scrolling {
    scroll-behavior: auto !important;
}

.palette-section {
    margin-bottom: 0;
    position: relative;
    padding-top: 2.5rem;
    margin-top: 0.5rem;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.split-view.active .palette-section {
    opacity: 1;
    transform: translateY(0);
    transition-delay: calc(var(--section-index, 0) * 0.1s + 0.3s);
}

.palette-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.split-view.active .palette-header {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.2s;
}

.selected-color {
    display: flex;
    align-items: center;
    gap: 0;
}

.color-preview {
    width: 100px;
    height: 100px;
    border-radius: 0;
    background-color: rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
}

.color-info {
    font-size: 0.55rem;
    background-color: transparent;
    padding: 0.5rem;
    width: 100%;
    text-align: left;
}

.close-palette {
    background: none;
    border: none;
    font-size: 1.1rem;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    color: var(--text-color);
    font-family: var(--primary-font);
    transition: transform 0.2s ease, opacity 0.2s ease;
    -webkit-font-smoothing: antialiased;
    text-rendering: geometricPrecision;
}

.close-palette:hover {
    opacity: 0.7;
    transform: rotate(90deg);
}

.palette-section h3 {
    font-size: 0.55rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: absolute;
    top: 1rem;
    left: 0.3rem;
    z-index: 10;
    background-color: transparent;
    color: #222222;
    padding: 0.5rem 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: calc(100% - 0.6rem);
}

.palette-header-icons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.download-palette {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    width: 0.8rem;
    height: 0.8rem;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    color: var(--accent-color);
}

.download-palette:hover {
    opacity: 1;
}

.add-variant {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    width: 0.8rem;
    height: 0.8rem;
    padding: 0;
    border: 0;
    background: transparent;
    opacity: 0.7;
    transition: opacity 0.2s ease, transform 0.2s ease;
    color: var(--accent-color);
}

.add-variant:hover {
    opacity: 1;
}

.add-variant:active {
    transform: scale(0.9);
}

.download-palette svg,
.add-variant svg {
    width: 100%;
    height: 100%;
}

.color-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0;
    margin-bottom: 0;
}

/* Custom grid layouts for each palette type */
.complementary-grid {
    display: grid;
    grid-template-columns: 1.6fr repeat(4, 1fr);
    gap: 0;
}

.analogous-grid {
    display: grid;
    grid-template-columns: 1.6fr repeat(4, 1fr);
    gap: 0;
}

.triadic-grid {
    display: grid;
    grid-template-columns: 1.6fr repeat(4, 1fr);
    gap: 0;
}

.square-grid,
.compound-grid,
.tetradic-grid {
    display: grid;
    grid-template-columns: 1.3fr repeat(3, 1fr);
    gap: 0;
}

.splitComplementary-grid {
    display: grid;
    grid-template-columns: 1.6fr repeat(4, 1fr);
    gap: 0;
}

.monochromatic-grid {
    display: grid;
    grid-template-columns: 2fr repeat(2, 1fr);
    grid-template-rows: 1fr 1fr;
    grid-auto-flow: row dense;
    gap: 0;
}

.monochromatic-grid .large-color {
    grid-row: span 2;
}

.shades-grid {
    display: grid;
    grid-template-columns: 2fr repeat(4, 1fr);
    gap: 0;
}

.tints-grid {
    display: grid;
    grid-template-columns: 2fr repeat(4, 1fr);
    grid-template-rows: 1fr;
    gap: 0;
}

.tints-grid .large-color {
    grid-column: 1;
    grid-row: 1;
    height: 120px;
}

.tints-grid .palette-color:not(.large-color) {
    height: 120px;
    display: flex;
    width: 100%;
}

.tints-grid .palette-color:not(.large-color) .palette-color-name {
    font-size: 0.6rem;
}

.tints-grid .palette-color:not(.large-color) .palette-color-preview {
    padding: 0.8rem 0.8rem 3rem 0.5rem;
}

.tones-grid {
    display: grid;
    grid-template-columns: 1.5fr repeat(2, 1fr);
    grid-template-rows: 1fr 1fr;
    gap: 0;
}

.tones-grid .large-color {
    grid-row: span 2;
}

.accent-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Base color container (first row) */
.accent-grid .large-color {
    width: 100%;
    height: 120px;
    margin-bottom: 0;
    position: relative;
    z-index: 1;
}

/* Container for all accent colors (second row) */
.accent-grid .accent-colors-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    width: 100%;
}

.accent-grid .palette-color:not(.large-color) {
    height: 60px;
    width: 100%;
}

/* Adjust accent palette layout for better visibility */
.accent-grid .palette-color-name {
    display: block;
    margin-bottom: 0.5rem;
}

.accent-grid .large-color .palette-color-label {
    bottom: 0;
    padding-bottom: 1rem;
}

.palette-color {
    width: 100%;
    height: 120px;
    display: flex;
    flex-direction: column;
    position: relative;
    border: none;
    outline: none;
    overflow: hidden;
    transition: transform 0.2s ease, opacity 0.2s ease;
    opacity: 0;
    transform: scale(0.95);
    cursor: pointer;
}

.split-view.active .palette-color {
    opacity: 1;
    transform: scale(1);
    transition-delay: calc(var(--color-index, 0) * 0.05s + 0.5s);
}

.palette-color:hover {
    z-index: 1;
    transition: transform 0.2s ease !important;
    transform: scale(0.9) !important;
}

.large-color {
    grid-column: span 1;
    grid-row: span 1;
    height: 120px;
}

.palette-color-preview {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.8rem 0.8rem 3rem 0.5rem;
}

.palette-color-name {
    font-size: 0.55rem;
    font-weight: 400;
    margin-bottom: 0.5rem;
    max-width: 100%;
    overflow: hidden;
    letter-spacing: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.large-color .palette-color-name {
    font-size: 0.55rem;
}

.palette-color-label {
    font-size: 0.55rem;
    text-align: left;
    background-color: transparent;
    padding: 0.5rem;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
}

/* Mobile adjustments for split view */
@media (max-width: 768px) {
    .split-view {
        flex-direction: column;
    }
    
    .split-view-left, 
    .split-view-right {
        width: 100%;
    }
    
    .split-view-left {
        display: none; /* Hide the image completely on mobile */
    }
    
    .split-view-right {
        height: 100%; /* Take up the full height */
        transform: translateY(20px); /* Slide up animation on mobile */
        opacity: 0;
    }
    
    .split-view.active .split-view-right {
        transform: translateY(0);
        opacity: 1;
        transition-delay: 0.1s;
    }
    
    .palette-color {
        height: 100px;
    }
    
    .large-color {
        height: 100px;
    }
    
    .palette-color-name {
        font-size: 0.5rem;
    }
    
    .large-color .palette-color-name {
        font-size: 0.5rem;
    }
    
    .palette-color-preview {
        padding: 0.45rem 0.4rem 2.35rem 0.4rem;
    }

    .palette-color-label {
        padding: 0.4rem;
        font-size: 0.48rem;
        letter-spacing: 0;
        line-height: 1.25;
    }
    
    .palette-section {
        padding-top: 2rem;
        margin-top: 0.5rem;
    }
    
    .palette-section h3 {
        top: 0.7rem;
        padding: 0.4rem 0;
    }
    
    .download-palette {
        width: 0.7rem;
        height: 0.7rem;
    }
}

.palettes-container {
    display: grid;
    grid-auto-rows: min-content;
    gap: 0;
    width: 100%;
    margin-top: 0;
    padding-bottom: 20px;
}

/* Hide main content when split view is active */
body.split-view-active main > .image-container {
    opacity: 0;
    visibility: hidden;
    position: absolute;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-delay: 0ms !important;
        transition-duration: 0.01ms !important;
    }
}
