:root {
    --bg-color: #ffde00; /* Vibrant Yellow */
    --panel-bg: #ffffff;
    --panel-border: #000000;
    --text-primary: #000000;
    --text-secondary: #333333;
    --accent-green: #00c48c; /* Spark Curiosity */
    --accent-blue: #32ade6;  /* Be Concise */
    --accent-coral: #ff5a5f; /* Add Yellow */
    --accent: #000000;
    --accent-hover: #333333;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 2rem;
}

.dashboard-container {
    display: flex;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    z-index: 1;
}

.sidebar {
    width: 320px;
    flex-shrink: 0;
    background: #fff;
    border: 4px solid #000;
    padding: 1.5rem;
    box-shadow: 12px 12px 0px 0px #000;
}

.sidebar h3 {
    margin-top: 0;
    text-transform: uppercase;
    font-weight: 900;
    border-bottom: 3px solid #000;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

.main-content {
    flex-grow: 1;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-item {
    padding: 0.75rem;
    border: 2px solid #000;
    cursor: pointer;
    transition: all 0.2s;
    background: #fff;
    color: #000;
}

.history-item:hover {
    background: #000;
    color: #fff;
    transform: translate(-4px, -4px);
    box-shadow: 4px 4px 0px 0px #ffde00;
}

.history-meta {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-bottom: 0.25rem;
}

.history-title {
    font-weight: 800;
    font-size: 0.9rem;
}

.history-details {
    font-size: 0.75rem;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

h1 {
    font-size: 3.5rem;
    font-weight: 900;
    letter-spacing: -2px;
    text-transform: uppercase;
}

header p {
    color: var(--text-primary);
    font-weight: 600;
    margin-top: 0.5rem;
    font-size: 1.2rem;
}

.accent {
    color: #000;
    background: none;
    -webkit-background-clip: initial;
    background-clip: initial;
}

/* High-Contrast Panels */
.glass-panel {
    background: var(--panel-bg);
    border: 6px solid #000;
    border-radius: 0;
    padding: 3rem;
    box-shadow: 20px 20px 0px 0px #000;
}

.glass-panel.wide {
    max-width: 1400px;
    width: 95vw;
    margin: 0 auto;
}

h2 {
    font-weight: 600;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 0.75rem;
}

h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    margin-top: 1.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
    width: 100%;
}

.form-row {
    display: flex;
    gap: 1rem;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

input, select {
    width: 100%;
    padding: 1rem;
    background: #fff;
    border: 3px solid #000;
    border-radius: 0;
    color: #000;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.2s;
}

input:focus, select:focus {
    outline: none;
    background: #fdfdfd;
    box-shadow: 6px 6px 0px 0px #000;
    transform: translate(-2px, -2px);
}

.form-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 3px dashed #000;
}

.form-section h3 {
    margin-top: 0;
    font-weight: 800;
    text-transform: uppercase;
    font-size: 1rem;
    color: #000;
}

.vector-input {
    display: flex;
    gap: 0.5rem;
}

.vector-input input {
    flex: 1;
    padding: 0.75rem;
    font-size: 0.9rem;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    cursor: pointer;
}

.checkbox-container input[type="checkbox"] {
    width: 25px;
    height: 25px;
    cursor: pointer;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 0.5rem;
}

.checkbox-grid label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.checkbox-grid input {
    width: 20px;
    height: 20px;
}

.lattice-legend {
    display: flex;
    gap: 1.5rem;
    background: #000;
    padding: 0.5rem 1rem;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.dot.cation { background: #0088ff; }
.dot.anion { background: #ff0000; }

.ref-link {
    color: #000;
    text-decoration: underline;
    font-weight: 700;
}

.ref-link:hover {
    background: #000;
    color: #fff;
}

/* Bold Minimalist Buttons */
.glow-on-hover {
    width: 100%;
    border: 4px solid #000;
    outline: none;
    color: #000;
    background: var(--accent-blue);
    cursor: pointer;
    position: relative;
    border-radius: 0;
    padding: 1.25rem;
    font-size: 1.4rem;
    font-weight: 900;
    text-transform: uppercase;
    margin-top: 1rem;
    transition: all 0.1s;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 8px 8px 0px 0px #000;
}

.glow-on-hover:hover {
    background: var(--accent-green);
    transform: translate(-4px, -4px);
    box-shadow: 12px 12px 0px 0px #000;
}

.glow-on-hover:active {
    transform: translate(2px, 2px);
    box-shadow: 4px 4px 0px 0px #000;
}

.glow-on-hover:before {
    display: none;
}

@keyframes glowing {
    0% { background-position: 0 0; }
    50% { background-position: 400% 0; }
    100% { background-position: 0 0; }
}

.btn-secondary {
    display: inline-block;
    padding: 1rem 2rem;
    background: #fff;
    color: #000;
    text-decoration: none;
    border-radius: 0;
    font-weight: 900;
    text-transform: uppercase;
    transition: all 0.1s;
    border: 4px solid #000;
    text-align: center;
    box-shadow: 6px 6px 0px 0px #000;
}
.btn-secondary:hover {
    background: var(--accent-coral);
    transform: translate(-2px, -2px);
    box-shadow: 8px 8px 0px 0px #000;
}

/* Loading State */
.spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-left: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.glow-on-hover.loading .spinner { display: block; }
.glow-on-hover.loading .btn-text { opacity: 0.8; }

/* Results Grid */
.result-grid {
    display: grid;
    grid-template-columns: 2.5fr 1fr;
    gap: 3rem;
}

.plot-container {
    background: #fff;
    border: 4px solid #000;
    padding: 0.5rem;
    display: block;
    width: 100%;
}

#bandPlot {
    width: 100%;
    min-height: 600px;
    height: 700px;
}

.log-box {
    background: #0f172a;
    border: 2px solid #000;
    border-radius: 0;
    padding: 1rem;
    height: 250px;
    overflow-y: auto;
    overflow-x: hidden;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.8rem;
    color: #34d399;
}

.log-box pre {
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
}

.param-list {
    list-style: none;
}
.param-list li {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}
.param-list li strong {
    color: var(--text-secondary);
}

.mt-4 { margin-top: 1.5rem; }

.error-box {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
}
.error-box p { color: var(--error); margin-bottom: 0.5rem;}
.error-box pre { font-family: monospace; color: #fca5a5; white-space: pre-wrap; font-size: 0.9rem;}

/* Progress Bar and Overlays */
.hidden {
    display: none !important;
}

.progress-bar-container {
    width: 100%;
    height: 30px;
    background: #fff;
    border-radius: 0;
    margin-top: 1.5rem;
    overflow: hidden;
    border: 4px solid #000;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-green);
    border-radius: 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 4px solid #000;
}

.progress-text {
    text-align: right;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    color: var(--text-secondary);
    font-weight: 600;
}

@media (max-width: 768px) {
    .result-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Input validation feedback ------------------------------------------ */

.field-hint {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.field-hint.hint-error {
    color: #c62828;
}

.validation-errors {
    background: #ffe8e8;
    border: 4px solid #000;
    border-left: 10px solid #ff5a5f;
    padding: 0.9rem 1.1rem;
    margin: 1rem 0;
    font-size: 0.85rem;
    color: #000;
    font-weight: 600;
}

.validation-errors ul {
    margin: 0.5rem 0 0;
    padding-left: 1.2rem;
}

.validation-errors li {
    margin: 0.25rem 0;
}

select:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* --- Busy / simulation-in-progress banner ------------------------------- */

.running-banner {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    background: #fff3c4;
    border: 4px solid #000;
    border-left: 10px solid #f5a623;
    padding: 0.85rem 1.1rem;
    margin-bottom: 1.25rem;
    font-size: 0.85rem;
    color: #000;
}

.running-banner .running-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
    font-weight: 600;
}

.running-banner .running-text span {
    font-size: 0.78rem;
    color: #4a4a4a;
}

.running-dot {
    width: 14px;
    height: 14px;
    border: 3px solid #000;
    border-radius: 50%;
    background: #f5a623;
    flex-shrink: 0;
    animation: running-pulse 1.2s ease-in-out infinite;
}

@keyframes running-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.25; }
}

.running-banner button {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 0.72rem;
    cursor: pointer;
}

button:disabled,
button.is-blocked {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(0.6);
}

/* --- Result interpretation note ----------------------------------------- */

.interp-note {
    background: #eef6ff;
    border: 4px solid #000;
    border-left: 10px solid #0066cc;
    padding: 1rem 1.2rem;
    margin: 0 0 1.5rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

.interp-note.interp-warn {
    background: #fff6e5;
    border-left-color: #e08600;
}

.interp-note h4 {
    margin: 0 0 0.6rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.interp-note p { margin: 0 0 0.6rem; }

.interp-action {
    font-weight: 700;
}

.interp-table {
    border-collapse: collapse;
    margin: 0.8rem 0;
    font-size: 0.85rem;
    width: 100%;
    max-width: 34rem;
}

.interp-table th,
.interp-table td {
    border: 2px solid #000;
    padding: 0.35rem 0.6rem;
    text-align: left;
}

.interp-table th { background: rgba(0, 0, 0, 0.06); }

.interp-verdict {
    font-size: 0.85rem;
    margin-top: 0.4rem;
}

.interp-details {
    margin-top: 0.8rem;
    border-top: 2px solid rgba(0, 0, 0, 0.25);
    padding-top: 0.6rem;
}

.interp-details summary {
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85rem;
}

.interp-details ul {
    margin: 0.6rem 0 0;
    padding-left: 1.2rem;
    font-size: 0.83rem;
}

.interp-details li { margin: 0.35rem 0; }

.interp-details code {
    background: rgba(0, 0, 0, 0.07);
    padding: 0 0.25rem;
}

@media (prefers-color-scheme: dark) {
    .interp-note { background: #10243a; color: #e8eef5; }
    .interp-note.interp-warn { background: #33260d; }
    .interp-table th { background: rgba(255, 255, 255, 0.08); }
    .interp-details code { background: rgba(255, 255, 255, 0.12); }
}
