body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 20px;
    background: var(--bg-gradient); /* Use gradient for body background */
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    transition: background-color 0.5s ease, color 0.5s ease; /* Smooth transition */
}

.container {
    background-color: var(--container-bg);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 800px;
    opacity: 0.8; /* Added opacity */
    transition: background-color 0.5s ease, box-shadow 0.5s ease; /* Smooth transition */
}

h1, h2 {
    color: var(--primary-dark-color); /* Changed to use variable */
    text-align: center;
    margin-bottom: 20px;
}

.header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.logo {
    height: 3.5em; /* 200% of the line height of H1 */
    margin-right: 15px;
}

.input-section, .controls-section {
    margin-bottom: 25px;
    padding: 15px;
    border: 1px solid #eee;
    border-radius: 5px;
    background-color: #f9f9f9;
}

.input-section label, .controls-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

.input-section input[type="text"],
.input-section input[type="date"] {
    width: calc(100% - 22px); /* Adjusted width to accommodate padding */
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    font-size: 16px;
    background-color: var(--input-bg);
    color: var(--text-color);
}

.input-section select,
.controls-section select {
    width: calc(100% - 22px); /* Adjusted width to accommodate padding */
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    font-size: 16px;
    background-color: var(--input-bg);
    color: var(--text-color);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24' 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 1.2em;
    padding-right: 30px; /* Ensure text doesn't overlap arrow */
}

body.dark-mode .input-section select,
body.dark-mode .controls-section select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23E0E0E0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.input-section button {
    display: block;
    width: 100%;
    padding: 12px 20px;
    background-color: var(--primary-color); /* Use variable */
    color: var(--button-text-color); /* New variable for button text */
    border: none;
    border-radius: 4px;
    font-size: 18px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.input-section button:hover {
    background-color: var(--primary-dark-color); /* Use variable */
}

.numerology-section {
    border: 1px solid var(--border-color); /* Use variable */
    border-radius: 5px;
    padding: 20px;
    margin-top: 20px;
    background-color: var(--section-bg); /* Use variable */
    transition: background-color 0.5s ease, border-color 0.5s ease; /* Smooth transition */
}

.numerology-section h2 {
    margin-top: 0;
    color: var(--primary-color); /* Changed to use variable */
    font-size: 22px;
}

.results-content {
    line-height: 1.6;
}

/* Lo Shu Grid Specific Styles */
.grid-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    width: 200px; /* Adjust as needed */
    margin: 20px auto; /* Center the grid */
    border: 1px solid var(--input-border); /* Use variable */
    padding: 5px;
    background-color: var(--grid-bg); /* Use variable */
    transition: background-color 0.5s ease, border-color 0.5s ease; /* Smooth transition */
}

.grid-cell {
    border: 1px solid var(--grid-border); /* Use variable */
    padding: 15px;
    text-align: center;
    font-size: 1.2em;
    font-weight: bold;
    background-color: var(--grid-cell-bg); /* Use variable */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 60px; /* Ensure consistent height */
    transition: background-color 0.5s ease, border-color 0.5s ease; /* Smooth transition */
}

.grid-cell .digit {
    font-size: 1.5em;
    color: var(--text-color); /* Use variable */
}

.grid-cell .count {
    font-size: 0.8em;
    color: var(--secondary-text-color); /* New variable for secondary text */
    margin-top: 5px;
}

.missing-number {
    background-color: #ffdddd; /* Light red for missing */
    color: #cc0000;
}

.repeated-number {
    background-color: #ddffdd; /* Light green for repeated */
    color: #008000;
}

#loShuDetails {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color); /* Use variable */
    transition: border-color 0.5s ease; /* Smooth transition */
}

#loShuMeanings {
    list-style-type: none;
    padding: 0;
}

/* Theme Switch Styles */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 15px;
}

.theme-switch-wrapper em {
    margin-left: 10px;
    font-size: 0.9em;
    color: var(--text-color);
    transition: color 0.5s ease; /* Smooth transition */
}

.theme-switch {
    display: inline-block;
    height: 34px;
    position: relative;
    width: 60px;
}

.theme-switch input {
    display: none;
}

.slider {
    background-color: #ccc;
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
}

.slider:before {
    background-color: #fff;
    bottom: 4px;
    content: "";
    height: 26px;
    left: 4px;
    position: absolute;
    transition: .4s;
    width: 26px;
}

input:checked + .slider {
    background-color: var(--primary-color); /* Use variable */
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Dark Mode Variables and Application */
:root {
    /* Light Mode Palette */
    --bg-gradient: linear-gradient(135deg, #F8F8F8 0%, #E8E8E8 100%);
    --text-color: #333333;
    --secondary-text-color: #666666;
    --button-text-color: #FFFFFF;
    --container-bg: #FFFFFF;
    --section-bg: #F0F0F0;
    --border-color: #E0E0E0;
    --primary-color: #66B2B2; /* Muted Teal */
    --primary-dark-color: #4D9999; /* Deeper Teal */
    --input-bg: #F9F9F9;
    --input-border: #CCCCCC;
    --grid-bg: #E8E8E8;
    --grid-cell-bg: #FFFFFF;
    --grid-border: #BBBBBB;
    --lo-shu-meaning-border: #4D9999; /* Deeper Teal */
    --link-color: #66B2B2; /* Muted Teal for links */
}

body.dark-mode {
    /* Dark Mode Palette */
    --bg-gradient: linear-gradient(135deg, #1A1A2E 0%, #2C2C4A 100%);
    --text-color: #E0E0E0;
    --secondary-text-color: #AAAAAA;
    --button-text-color: #FFFFFF;
    --container-bg: #2C2C4A;
    --section-bg: #3A3A5C;
    --border-color: #4A4A6A;
    --primary-color: #8D9EFF; /* Soft Lavender/Blue */
    --primary-dark-color: #6A7BCC; /* Deeper Lavender/Blue */
    --input-bg: #3A3A5C;
    --input-border: #777777;
    --grid-bg: #3A3A5C;
    --grid-cell-bg: #4A4A6A;
    --grid-border: #6A6A8A;
    --lo-shu-meaning-border: #8D9EFF; /* Soft Lavender/Blue */
    --link-color: #8D9EFF; /* Soft Lavender/Blue for links */
}

/* Apply variables */
body {
    background: var(--bg-gradient); /* Use gradient */
    color: var(--text-color);
}

.container {
    background-color: var(--container-bg);
}

h1, h2 {
    color: var(--primary-dark-color);
}

.input-section, .controls-section {
    border-color: var(--border-color);
    background-color: var(--input-bg);
}

.input-section input[type="text"],
.input-section input[type="date"] {
    border-color: var(--input-border);
    background-color: var(--input-bg);
    color: var(--text-color);
}

.input-section button {
    background-color: var(--primary-color);
    color: var(--button-text-color);
}

.input-section button:hover {
    background-color: var(--primary-dark-color);
}

.numerology-section {
    border-color: var(--border-color);
    background-color: var(--section-bg);
}

.numerology-section h2 {
    color: var(--primary-color);
}

.grid-container {
    border-color: var(--input-border);
    background-color: var(--grid-bg);
}

.grid-cell {
    border-color: var(--grid-border);
    background-color: var(--grid-cell-bg);
}

.grid-cell .digit {
    color: var(--text-color);
}

/* CTA Link Color */
.learn-more-cta {
    color: var(--link-color);
    text-decoration: none;
    font-weight: bold;
    margin-left: 5px;
}

.learn-more-cta:hover {
    text-decoration: underline;
}

.missing-number {
    background-color: #ffdddd; /* Light red for missing */
    color: #cc0000;
}

.repeated-number {
    background-color: #ddffdd; /* Light green for repeated */
    color: #008000;
}

body.dark-mode .missing-number {
    background-color: #800000; /* Darker red for missing in dark mode */
    color: #ffaaaa;
}

body.dark-mode .repeated-number {
    background-color: #004d00; /* Darker green for repeated in dark mode */
    color: #aaffaa;
}

/* Particles.js background */
#particles-js {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: transparent;
    background-image: url("");
    background-repeat: no-repeat;
    background-size: cover;
    background-position: 50% 50%;
    z-index: -1; /* Ensure it's behind other content */
}

#loShuMeanings li {
    margin-bottom: 8px;
    padding-left: 10px;
    border-left: 3px solid var(--lo-shu-meaning-border); /* Changed to use variable */
}

footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--secondary-text-color);
}

footer a {
    color: var(--link-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

.social-links a {
    margin-left: 15px;
}

.social-links svg {
    stroke: var(--text-color);
}

/* Accordion Styles */
.accordion-group {
    margin-top: 20px;
}

.accordion-header {
    cursor: pointer;
    padding: 15px;
    background-color: var(--section-bg);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    margin-bottom: 5px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--primary-color);
    font-size: 22px;
}

.accordion-header:hover {
    background-color: var(--primary-color);
    color: var(--button-text-color);
}

.accordion-header::after {
    content: '+';
    font-size: 1.2em;
    transition: transform 0.3s ease;
}

.accordion-header.active::after {
    content: '-';
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
    background-color: var(--section-bg);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 5px 5px;
    padding: 0 15px; /* Initial padding when collapsed */
}

.accordion-content p {
    margin-bottom: 10px;
}
