 /* Define CSS variables for light and dark modes */
 :root {
    /* Light mode variables */
    --background-color: #e0e0e0;
    --text-color: #333;
    --heading-color: #2c3e50;
    --canvas-border: #2c3e50;
    --canvas-bg: #fff;
    --canvas-placeholder-bg: #000;
    --canvas-placeholder-text: #fff;
    --controls-bg: #ffffff;
    --controls-shadow: rgba(0, 0, 0, 0.1);
    --input-bg: #f9f9f9;
    --input-border: #ccc;
    --input-text: #333;
    --input-placeholder: #888;
    --button-bg: #3498db;
    --button-bg-hover: #2980b9;
    --button-text: #fff;
    --color-swatch-border: #ccc;
    --hover-border: #3498db;
    --info-bg: #ffffff;
    --info-shadow: rgba(0, 0, 0, 0.1);
    --footer-bg: #e0e0e0;
    --link-color: #3498db;
}

/* Dark mode variables */
[data-theme="dark"] {
    --background-color: #1a1a1a;
    --text-color: #e0e0e0;
    --heading-color: #e0e0e0;
    --canvas-border: #666;
    --canvas-bg: #333;
    --canvas-placeholder-bg: #333;
    --canvas-placeholder-text: #e0e0e0;
    --controls-bg: #2a2a2a;
    --controls-shadow: rgba(255, 255, 255, 0.1);
    --input-bg: #333;
    --input-border: #555;
    --input-text: #e0e0e0;
    --input-placeholder: #aaa;
    --button-bg: #4a90e2;
    --button-bg-hover: #357abd;
    --button-text: #fff;
    --color-swatch-border: #555;
    --hover-border: #4a90e2;
    --info-bg: #2a2a2a;
    --info-shadow: rgba(255, 255, 255, 0.1);
    --footer-bg: #1a1a1a;
    --link-color: #4a90e2;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--background-color);
    margin: 0;
    padding: 20px;
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}
h1 {
    font-size: 32px;
    color: var(--heading-color);
    margin: 20px 0;
}
h2 {
    font-size: 24px;
    color: var(--heading-color);
    margin-top: 20px;
}
.main-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}
.left-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 500px;
}
#canvas {
    border: 2px solid var(--canvas-border);
    background-color: var(--canvas-bg);
    border-radius: 8px;
    display: block; /* Ensures it behaves like a block element for responsive scaling */
    max-width: 100%; /* Allows it to scale down if its intrinsic width is larger than its parent */
    height: auto; /* Maintains aspect ratio when scaling down */
    cursor: pointer;
    transition: border-color 0.3s ease;
}
#canvas:hover {
    border-color: var(--hover-border);
}
.controls {
    flex: 1;
    max-width: 400px;
    background-color: var(--controls-bg);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px var(--controls-shadow);
    display: flex;
    flex-direction: column;
}
.control-group {
    margin-bottom: 15px;
}
label {
    display: block;
    margin-bottom: 5px;
    font-weight: 700;
    color: var(--text-color);
}
input[type="text"],
select,
input[type="range"] {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid var(--input-border);
    border-radius: 5px;
    background-color: var(--input-bg);
    color: var(--input-text);
    font-size: 16px;
    transition: border-color 0.3s ease;
}
input[type="text"]:focus,
select:focus,
input[type="range"]:focus {
    border-color: var(--hover-border);
    outline: none;
}
input[type="text"]::placeholder,
select::placeholder {
    color: var(--input-placeholder);
}
button {
    background-color: var(--button-bg);
    color: var(--button-text);
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin: 5px;
    font-size: 14px;
    transition: background-color 0.3s ease;
}
button:hover {
    background-color: var(--button-bg-hover);
}
input[type="file"] {
    display: block;
    margin: 0 auto;
    color: var(--text-color);
}
/* Mosaic-style color selector */
#colorSelector {
    display: grid;
    grid-template-columns: repeat(7, 40px);
    grid-template-rows: repeat(2, 40px);
    gap: 10px;
    justify-content: center;
    max-width: 340px;
    margin: 0 auto;
}
.color-swatch {
    width: 40px;
    height: 40px;
    border-radius: 5px;
    cursor: pointer;
    border: 2px solid var(--color-swatch-border);
    transition: transform 0.2s ease, border-color 0.3s ease;
}
.color-swatch:hover {
    transform: scale(1.1);
    border-color: var(--hover-border);
}
.color-swatch.selected {
    border-color: var(--hover-border);
    box-shadow: 0 0 5px var(--hover-border);
}
/* How to Use and Disclaimer sections */
.info-section {
    width: 100%;
    max-width: 500px;
    margin: 10px 0;
    text-align: left;
    background-color: var(--info-bg);
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 2px 10px var(--info-shadow);
    flex-grow: 1;
    color: var(--text-color);
}
.info-section p {
    margin: 10px 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-color);
}
.info-section ul {
    margin: 10px 0;
    padding-left: 20px;
}
.info-section li {
    margin: 5px 0;
    font-size: 14px;
    color: var(--text-color);
}
/* Footer */
footer {
    margin-top: auto;
    padding: 10px 0;
    width: 100%;
    text-align: center;
    background-color: var(--footer-bg);
    color: var(--text-color);
    font-size: 14px;
}
footer a {
    color: var(--link-color);
    text-decoration: none;
}
footer a:hover {
    text-decoration: underline;
}
/* Theme toggle button */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: var(--button-bg);
    color: var(--button-text);
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}
.theme-toggle:hover {
    background-color: var(--button-bg-hover);
}
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
        align-items: center;
    }
    .left-section,
    #canvas,
    .controls,
    .info-section {
        max-width: 100%;
        width: 100%;
    }
    .left-section {
        min-height: auto;
    }
    .info-section {
        flex-grow: 0;
    }
    .theme-toggle {
        top: 10px;
        right: 10px;
    }
}