:root {
    --primary: #2196f3;
    --secondary: #757575;
    --background: #1a1a1a;
    --glass: rgba(255, 255, 255, 0.1);
    --error: #ff4444;
    --success: #4CAF50;
    --warning: #FFC107;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --transition-speed: 0.3s;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

.video-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}
#bg-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.6;
    filter: blur(3px) brightness(100%);
}

/* Layout */
.container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* Control Panel */
.control-panel {
    background: var(--glass);
    padding: 2rem;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform var(--transition-speed) ease;
    box-shadow: var(--shadow);
}

.control-panel:hover {
    transform: translateY(-2px);
}

/* Toggle Switch Styles */
.toggle-switch-container {
    display: flex;
    align-items: center;
    justify-content: space-between; /* Aligns label and switch nicely */
    margin-top: 1rem;
    margin-bottom: 1rem;
    padding: 0.5rem 0; /* Optional padding */
}

.toggle-switch-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-right: 10px; /* Space between label and switch */
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;  /* Adjusted width */
    height: 28px; /* Adjusted height */
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--secondary); /* Off state color */
    transition: .4s;
    border-radius: 28px; /* Fully rounded */
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px; /* Adjusted size */
    width: 20px;  /* Adjusted size */
    left: 4px;    /* Adjusted position */
    bottom: 4px;  /* Adjusted position */
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

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

input:focus + .slider {
    box-shadow: 0 0 1px var(--primary);
}

input:checked + .slider:before {
    transform: translateX(22px); /* Adjusted translation */
}

/* Rounded sliders */
.slider.round {
    border-radius: 28px;
}

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


/* Input Group & Titles */
.input-group {
    display: grid;
    gap: 1.5rem;
    margin-top: 1rem;
    margin-bottom: 1.5rem;
}

.group-title {
    font-size: 1.1rem;
    color: var(--primary);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--secondary);
}

.axial-ratios-inputs {
    display: grid;
    gap: 1rem;
}


.input-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
}

/* Labels */
label { /* General label styling */
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: color var(--transition-speed) ease;
}

/* Inputs & Select Elements */
input, select {
    padding: 0.8rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--primary);
    color: var(--text-primary);
    border-radius: 5px;
    transition: all var(--transition-speed) ease;
    font-size: 1rem;
    font-family: inherit;
}

select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="white" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
    background-repeat: no-repeat;
    background-position: right 0.7em top 50%;
    background-size: 1.2em auto;
    padding-right: 2.5em;
}

select option {
    background: var(--background);
    color: var(--text-primary);
}


input:focus, select:focus {
    outline: none;
    box-shadow: 0 0 10px var(--primary);
    background: rgba(0, 0, 0, 0.4);
}

input.valid {
    border-color: var(--success);
}

input.invalid {
    border-color: var(--error);
}

input:disabled {
    background-color: rgba(0, 0, 0, 0.2);
    border-color: var(--secondary);
    cursor: not-allowed;
    opacity: 0.6;
}


/* Tooltips */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
}

/* Buttons */
.button-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1.5rem;
}

.primary-btn, .secondary-btn {
    padding: 0.8rem;
    border: none;
    color: var(--text-primary);
    border-radius: 5px;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    font-size: 1rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.primary-btn {
    background: var(--primary);
}

.secondary-btn {
    background: var(--secondary);
}

.primary-btn:hover, .secondary-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
    box-shadow: var(--shadow);
}

.primary-btn:active, .secondary-btn:active {
    transform: translateY(1px);
    filter: brightness(0.9);
}

.primary-btn:focus-visible, .secondary-btn:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Visualization Container */
.visualization-container {
    position: relative;
    width: 100%;
    height: 70vh;
    transition: height var(--transition-speed) ease;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

#scene-container {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 1rem;
    border-radius: 10px;
    z-index: 10;
}

.loader {
    width: 40px;
    height: 40px;
    border: 4px solid var(--text-secondary);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Solution Section */
.solution-section {
    grid-column: 1 / -1;
    background: var(--glass);
    padding: 2rem;
    border-radius: 15px;
    margin-top: 2rem;
    transition: transform var(--transition-speed) ease;
    box-shadow: var(--shadow);
}

.solution-section:hover {
    transform: translateY(-2px);
}

/* Messages */
.error-message, .feedback-message { /* Combined for general styling */
    color: var(--error); /* Default to error color, will be overridden by type class */
    margin-top: 1rem;
    display: none;
    padding: 0.5rem;
    border-radius: 5px;
    background: rgba(255, 68, 68, 0.1); /* Default to error background */
    transition: all var(--transition-speed) ease;
    text-align: center;
}
.feedback-message.success { background-color: rgba(76, 175, 80, 0.1); color: var(--success); }
.feedback-message.warning { background-color: rgba(255, 193, 7, 0.1); color: var(--warning); }
.feedback-message.info { background-color: rgba(33, 150, 243, 0.1); color: var(--primary); }
/* Ensure error type also uses feedback-message styles if applied */
.error-message.error, .feedback-message.error { background-color: rgba(255, 68, 68, 0.1); color: var(--error); }


.validation-message {
    font-size: 0.8rem;
    color: var(--error);
    min-height: 1rem;
    transition: opacity var(--transition-speed) ease;
}

/* Steps */
.step {
    margin: 1.5rem 0;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    transition: transform var(--transition-speed) ease;
}
.step:hover {
    transform: translateX(5px);
}
.step .values-container {
    margin-top: 0.5rem;
    font-size: 0.9em;
    color: var(--text-secondary);
}
.step .values-container ul {
    list-style-type: none;
    padding-left: 0;
}
.step .values-container li {
    margin-bottom: 0.25rem;
}


/* Loading Indicator */
.script-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--primary);
    color: var(--text-primary);
    text-align: center;
    padding: 0.5rem;
    z-index: 1000;
    transition: opacity var(--transition-speed) ease;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root { }
}

/* Print Styles */
@media print {
    body { background: white; color: black; }
    .control-panel, .visualization-container { break-inside: avoid; }
    .button-group, .loading-overlay, .script-loading, .video-background, .toggle-switch-container { display: none; }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container { grid-template-columns: 1fr; padding: 1rem; }
    .visualization-container { height: 50vh; }
    .button-group { grid-template-columns: 1fr; }
    [data-tooltip]:hover::after { display: none; }
    input, button, select { font-size: 16px; }
    .toggle-switch-container { flex-direction: column; align-items: flex-start; gap: 0.5rem;}
}

/* KaTeX Styling */
.katex { font-size: 1.1em !important; }

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
