*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #a84;
    color: #333;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
    font-size: 15px; /* Reduce all font sizes by 1 (by setting base to 15px) */
}

header {
    background: linear-gradient(to right, #448, #226, #448); /* Changed gradient for light outside, dark inside */
    color: white;
    border: 1px solid #337;
    padding: 15px 0;
    border-radius: 8px;
    width: 100%;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    margin-top: 20px;
}

h1 {
    margin: 0;
    font-size: 1.9em; /* Adjusted from 2em */
}

main {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    width: 100%;
    max-width: 1200px;
    justify-content: center;
}

section {
    background-color: #aaa;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    flex: 1;
    min-width: 300px; /* Minimum width for sections */
}

.input-section {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    flex: 2; /* Allow input section to take more space */
    min-width: 600px;
}

.list-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 280px;
}

.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between; /* Space out label and buttons */
    margin-bottom: 8px; /* Maintain small gap before textarea */
}

.list-header label {
    margin-bottom: 0; /* Override default label margin */
}

label {
    margin-bottom: 8px;
    font-weight: bold;
    color: #444;
}

textarea {
    background: #dfe;
    width: 100%;
    height: 350px; /* Increased height from 250px */
    padding: 10px;
    border: 1px solid #44a;
    border-radius: 4px;
    font-size: 0.85em; /* Adjusted from 0.95em */
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
    overflow: auto; /* Ensure starting lists are scrollable */
}

.button-group {
    display: none; /* Hide old button groups */
}

.button-group-inline {
    display: flex;
    gap: 5px; /* Smaller gap for inline buttons */
}

.icon-button {
    width: 28px; /* Square and smaller */
    height: 28px;
    padding: 0;
    border: none;
    background-color: transparent; /* No background color by default */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease-in-out;
    border-radius: 4px;
    font-size: 1.4em; /* Increased font size for UTF-8 icons */
}

.icon-button img {
    width: 18px; /* Icon size */
    height: 18px;
    vertical-align: middle;
}

.icon-button:hover {
    background-color: #e0e0e0;
}

.icon-button.active {
    background-color: #e0f7e9;
    border: 1px solid #28a745;
}

button#copyA, button#copyB, button#copyOutput, button#copyOutput2 {
    background-color: transparent; /* Set specific background for copy if needed, or rely on general icon-button */
}

button#clearA, button#clearB, button#clearOutput, button#clearOutput2 {
    background-color: transparent; /* Set specific background for clear if needed */
}

button#countA, button#countB {
    background-color: transparent; /* Set specific background for count if needed */
}

/* Hover effects for specific icon buttons */
button#copyA:hover, button#copyB:hover, button#copyOutput:hover, button#copyOutput2:hover {
    background-color: #d1ecf1; /* Light blue on hover */
}

button#pasteA:hover, button#pasteB:hover { /* NEW: Paste button hover */
    background-color: #cce5ff; /* Slightly different light blue for paste */
}

button#clearA:hover, button#clearB:hover, button#clearOutput:hover, button#clearOutput2:hover {
    background-color: #f8d7da; /* Light red on hover */
}

button#countA:hover, button#countB:hover, button#countResultA:hover, button#countResultB:hover, button#countResultD:hover { /* Updated: Include new count buttons */
    background-color: #e2e3e5; /* Light grey on hover */
}

button#processBtn {
    background: linear-gradient(to right, #34d058, #28a745, #34d058); /* Changed gradient for light outside, dark inside */
    color: white; /* Set text color to white */
    font-size: 1.0em; /* Adjusted from 1.1em */
    padding: 12px 20px;
    margin-top: 20px;
    width: 100%;
}

button#processBtn:hover {
    background: linear-gradient(to right, #2dbd4a, #218838, #2dbd4a); /* Darker gradient on hover, maintaining light outside, dark inside */
}

.controls-section {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12.5px; /* Reduced gap from 25px */
}

.controls-section h2 {
    margin-top: 0;
    color: #444;
}

.option-group {
    width: 100%;
    padding: 15px;
    border: 1px solid #44a;
    border-radius: 6px;
    background-color: #bed;
}

.option-group h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #007bff; /* A distinct color for group headings */
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 8px;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
    font-weight: normal;
}

.checkbox-group input[type="checkbox"] {
    transform: scale(1.1); /* Slightly reduce scale for better visual balance with smaller text */
    cursor: pointer;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
    font-weight: normal;
}

.radio-group input[type="radio"] {
    transform: scale(1.1); /* Slightly reduce scale for better visual balance with smaller text */
    cursor: pointer;
}

#similarityThresholdContainer {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap; /* Allow wrapping for responsiveness */
}

#similarityThresholdContainer label,
#splitControlsContainer label {
    font-size: 0.85em; /* Ensure labels within these containers also get reduced font size */
}

#similarityThresholdContainer input[type="number"],
#splitControlsContainer input[type="number"] {
    width: 60px;
    padding: 4px; /* Slightly reduce padding */
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 0.85em; /* Also reduce font size for number inputs */
}

#splitControlsContainer {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 5px;
    border-top: 1px dashed #eee;
}

#splitControlsContainer .radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

#splitControlsContainer .radio-group label {
    display: flex;
    align-items: center;
    gap: 5px;
}

.report-message {
    margin-top: 10px;
    font-size: 0.9em;
    color: #007bff;
    text-align: center;
    width: 100%;
    font-weight: bold;
}

.hidden {
    display: none !important;
}

.output-section {
    flex: 2;
    min-width: 300px;
    display: flex; /* Make output section a flex container */
    flex-direction: column; /* Stack output lists vertically */
    gap: 20px; /* Space between output lists */
}

/* Responsive Design */
@media (max-width: 768px) {
    main {
        flex-direction: column;
        align-items: center;
    }

    .input-section, .output-section, .controls-section {
        width: 100%;
        min-width: unset;
    }

    .list-container {
        width: 100%;
    }

    textarea {
        height: 150px;
    }

    .button-group {
        flex-direction: column; /* Stack buttons vertically on small screens */
        align-items: flex-start;
    }
    button {
        width: 100%; /* Make buttons full width */
    }

    .output-section {
        flex-direction: column; /* Stack output lists vertically */
    }
}