:root {
    --primary-purple: #a86ede; /* Updated primary purple */
    --secondary-blue: #2575fc; /* Kept for potential gradient use */
    --light-bg: #f3f1f1; /* Updated light background for cards */
    --dark-text: #333;
    --medium-text: #555;
    --light-border: #ddd;
    --hover-purple: #8e4edb; /* Adjusted hover purple */
    --app-bg-gradient: linear-gradient(135deg, #a86ede 0%, #8e4edb 100%); /* Updated gradient */
}

body {
    font-family: 'KaiTi', 'STKaiti', serif; /* Changed font to KaiTi */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background: var(--app-bg-gradient);
    color: var(--dark-text);
}

.app-title {
    color: var(--light-bg);
    margin-bottom: 30px;
    font-size: 3em; /* Increased font size */
    font-family: 'KaiTi', serif; /* Set font to KaiTi */
    font-weight: bold; /* Set font weight to bold */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.container {
    display: flex;
    gap: 25px;
    padding: 20px;
    max-width: 1400px;
    width: 100%;
    align-items: stretch; /* Changed to stretch to make heights equal */
}

.card {
    background-color: var(--light-bg);
    border-radius: 15px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
    padding: 30px;
    box-sizing: border-box;
    display: flex; /* Added flex for internal layout */
    flex-direction: column; /* Added flex for internal layout */
}

.settings-panel {

    min-width: 450px;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.preview-panel {
    flex: 2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

h2 {
    color: var(--primary-purple);
    margin-top: 0;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--light-border);
    font-size: 1.8em;
}

.control-group {
    margin-bottom: 10px; /* Adjusted margin */
    padding: 10px; /* Added padding for the box effect */
    border: 1px solid var(--light-border); /* Added border for the box effect */
    border-radius: 8px; /* Rounded corners for the box */
    display: flex; /* Use flex for internal alignment */
    flex-direction: column; /* Stack elements vertically */
}

.upload-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
}

.upload-group #fileName {
    font-size: 0.9em;
    color: var(--medium-text);
}

.control-group label {
    display: block;
    margin-bottom: 5px; /* Adjusted margin */
    font-weight: bold; /* Kept bold */
    color: var(--medium-text);
    font-size: 16px; /* Consistent font size */
    font-family: 'KaiTi', serif; /* Set font to KaiTi */
}

.control-group input[type="number"],
.control-group input[type="text"],
.control-group select,
.control-group textarea {
    width: calc(100% - 16px);
    padding: 10px;
    border: 1px solid var(--light-border);
    border-radius: 8px;
    font-size: 15px;
    box-sizing: border-box;
}

.control-group input[type="file"] {
    width: 100%;
    padding: 5px;
    border: 1px solid var(--light-border);
    border-radius: 8px;
    font-size: 15px;
    box-sizing: border-box;
}

.control-group input[type="color"] {
    width: 45px;
    height: 35px;
    border: none;
    vertical-align: middle;
    cursor: pointer;
    border-radius: 5px;
    overflow: hidden;
}

.hex-input {
    width: 90px !important;
    margin-left: 10px;
}

.control-group-inline {
    display: flex;
    gap: 15px; /* Adjusted gap */
    margin-bottom: 10px; /* Adjusted margin */
    align-items: center;
}

.control-group-inline .control-group {
    flex: 1;
    margin-bottom: 0;
    padding: 10px; /* Added padding for the box effect */
    border: 1px solid var(--light-border); /* Added border for the box effect */
    border-radius: 8px; /* Rounded corners for the box */
}

.control-group-grid-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.control-group-grid {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
}

.control-group-grid .control-group {
    flex: 1;
    margin-bottom: 0;
}

.color-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.background-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--light-border);
    border-radius: 8px;
}

.background-options .control-group-inline {
    margin-bottom: 0;
}

.control-group-inline label {
    white-space: nowrap;
    font-size: 16px; /* Consistent font size */
}



.control-group input[type="range"] {
    width: calc(100% - 12px);
    -webkit-appearance: none;
    height: 10px;
    background: var(--light-border);
    border-radius: 5px;
    outline: none;
    opacity: 0.8;
    transition: opacity .2s;
}

.control-group input[type="range"]:hover {
    opacity: 1;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    background: var(--primary-purple);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    background: var(--primary-purple);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 15px;
    margin-top: 20px;
}

.actions button {
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 17px;
    transition: all 0.3s ease;
    flex: 1;
    font-weight: bold;
}

.main-actions button {
    background-color: var(--primary-purple);
    color: var(--light-bg);
    box-shadow: 0 4px 10px rgba(106, 17, 203, 0.4);
}

.main-actions button:hover {
    background-color: var(--hover-purple);
    box-shadow: 0 6px 15px rgba(106, 17, 203, 0.5);
    transform: translateY(-2px);
}

.secondary-actions button {
    background-color: var(--primary-purple);
    color: var(--light-bg);
    border: none;
    box-shadow: none;
}

.secondary-actions button:hover {
    background-color: var(--hover-purple);
    box-shadow: 0 6px 15px rgba(106, 17, 203, 0.5);
    transform: translateY(-2px);
}

canvas {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 10px;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

textarea {
    resize: none;
    overflow-y: hidden;
    min-height: 80px; /* Slightly increased min-height */
    line-height: 1.5;
}