:root {
    --bg-color: #f0f9ff;
    --primary-color: #ff6b6b;
    --secondary-color: #4ecdc4;
    --accent-color: #ffe66d;
    --text-color: #2b2b2b;
    --card-bg: #ffffff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Fredoka One', cursive, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background-image: radial-gradient(var(--secondary-color) 10%, transparent 10%),
                      radial-gradient(var(--accent-color) 10%, transparent 10%);
    background-size: 50px 50px;
    background-position: 0 0, 25px 25px;
    /* Soften the background pattern */
    background-color: #e0f2fe;
    opacity: 0.95;
}

.container {
    background-color: var(--card-bg);
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 1100px;
    padding: 40px;
    text-align: center;
    position: relative;
    z-index: 1;
    border: 4px solid white;
}

header h1 {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 10px;
    text-shadow: 2px 2px 0px var(--accent-color);
}

header p {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 12px;
    font-family: system-ui, -apple-system, sans-serif;
    font-weight: 500;
}

.sister-app-link {
    display: inline-block;
    background: linear-gradient(135deg, #a29bfe, #6c5ce7);
    color: white;
    text-decoration: none;
    padding: 10px 22px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    font-family: system-ui, -apple-system, sans-serif;
    box-shadow: 0 4px 0 #4a3ab5;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    margin-bottom: 18px;
}

.sister-app-link:hover {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #4a3ab5;
}

.input-section {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

input[type="text"] {
    flex: 1;
    min-width: 250px;
    max-width: 400px;
    padding: 15px 25px;
    font-size: 2rem;
    border: 4px solid var(--secondary-color);
    border-radius: 50px;
    outline: none;
    text-transform: uppercase;
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.05);
}

input[type="text"]:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(255, 107, 107, 0.3);
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.5rem;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 0 #cc5555;
    transition: all 0.1s ease;
    text-transform: uppercase;
}

button:hover {
    transform: translateY(2px);
    box-shadow: 0 4px 0 #cc5555;
    background-color: #ff5252;
}

button:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 #cc5555;
}

button:disabled {
    background-color: #cccccc;
    box-shadow: 0 6px 0 #999999;
    cursor: not-allowed;
    transform: translateY(0);
}

.display-section {
    min-height: 400px;
    border: 4px dashed #e2e8f0;
    border-radius: 20px;
    background-color: #f8fafc;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

#graphicContainer {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: scaleIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

#graphicContainer svg {
    max-width: 100%;
    max-height: 350px;
    width: auto;
    height: auto;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.1));
}

.spinner {
    width: 60px;
    height: 60px;
    border: 8px solid rgba(78, 205, 196, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    border-right-color: var(--accent-color);
    border-bottom-color: var(--secondary-color);
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto 20px;
}

#loading p {
    font-size: 1.5rem;
    color: var(--secondary-color);
    animation: pulse 1.5s infinite;
}

.hidden {
    display: none !important;
}

.text-danger {
    color: #ef4444;
    font-size: 1.2rem;
    font-family: system-ui, -apple-system, sans-serif;
    font-weight: bold;
    background: #fee2e2;
    padding: 15px 25px;
    border-radius: 12px;
    border: 2px solid #ef4444;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; transform: scale(1.05); }
    100% { opacity: 0.6; }
}

@keyframes scaleIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.split-layout {
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin-top: 20px;
    flex-wrap: wrap; /* allow wrapping on smaller devices */
}

@media (min-width: 768px) {
    .split-layout {
        flex-direction: row;
        align-items: flex-start;
    }
}

.split-layout main {
    flex: 2 1 400px;
    min-width: 0; /* Important for flex children to allow text/content wrapping */
}

.sidebar-gallery {
    flex: 1 1 320px;
    background-color: #f8fafc;
    border: 4px dashed #e2e8f0;
    border-radius: 20px;
    padding: 20px;
    height: 600px;
    display: flex;
    flex-direction: column;
    max-width: 100%; /* Prevent overflow on small screens */
    box-sizing: border-box;
}

.sidebar-gallery h2 {
    color: var(--secondary-color);
    margin-bottom: 15px;
    font-size: 1.5rem;
    text-align: center;
}

.gallery-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
    padding-right: 5px;
    flex: 1;
}

/* Custom Scrollbar for gallery */
.gallery-grid::-webkit-scrollbar {
    width: 8px;
}
.gallery-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}
.gallery-grid::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 4px;
}

.gallery-item {
    background: white;
    border-radius: 12px;
    padding: 10px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 2px solid transparent;
    position: relative; /* For absolutely positioned delete button */
}

.gallery-item:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border-color: var(--primary-color);
}

.delete-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #ff4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    padding: 0;
    z-index: 10;
}

.delete-btn:hover {
    background-color: #cc0000;
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

.gallery-item img {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 8px;
    object-fit: contain;
    background-color: white;
}

.gallery-item span {
    font-weight: bold;
    color: var(--text-color);
    font-size: 1.1rem;
    text-transform: uppercase;
}

@media (max-width: 600px) {
    header h1 { font-size: 2rem; }
    .container { padding: 20px; }
    input[type="text"] { font-size: 1.5rem; }
}

/* ── Gallery skeleton loader ─────────────────────────────────── */
@keyframes skeletonShimmer {
    0%   { background-position: -400px 0; }
    100% { background-position:  400px 0; }
}

.gallery-skeleton {
    pointer-events: none;
    cursor: default !important;
    border-color: transparent !important;
}
.gallery-skeleton:hover {
    transform: none !important;
    box-shadow: none !important;
}

.skeleton-img,
.skeleton-label {
    background: linear-gradient(90deg, #e8e8e8 25%, #f5f5f5 50%, #e8e8e8 75%);
    background-size: 800px 100%;
    animation: skeletonShimmer 1.4s ease-in-out infinite;
    border-radius: 8px;
}

.skeleton-img {
    width: 100%;
    aspect-ratio: 1;
    margin-bottom: 8px;
}

.skeleton-label {
    width: 60%;
    height: 18px;
    margin: 0 auto;
}

.gallery-load-more {
    text-align: center;
    padding: 8px 0;
    font-size: 0.85rem;
    color: #aaa;
    font-family: system-ui, sans-serif;
}
