:root {
    --bg-color: #111115;
    --card-bg: rgba(28, 28, 33, 0.85);
    --accent: #4a90e2;
    --text-main: #ffffff;
    --text-muted: #a0a0a0;
}

body {
    margin: 0;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
}

#main-nav-placeholder {
    position: relative;
    z-index: 20;
    width: 100%;
}

#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    cursor: grab;
}
#canvas-container:active { cursor: grabbing; }

/* UI Card */
.ui-card {
    position: absolute;
    top: 100px;
    left: 20px;
    width: 320px;
    max-width: calc(100% - 40px);
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 10;
    user-select: none;
    max-height: 80vh;
    overflow-y: auto;
}
.ui-card::-webkit-scrollbar { width: 6px; }
.ui-card::-webkit-scrollbar-track { background: transparent; }
.ui-card::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

/* Visualizations */
.viz-wrapper { margin-bottom: 20px; }
.viz-header {
    font-size: 0.7rem; text-transform: uppercase; color: var(--text-muted);
    letter-spacing: 0.05em; margin-bottom: 6px;
}
.viz-container {
    background: rgba(0,0,0,0.3); border-radius: 12px; padding: 10px;
    border: 1px solid rgba(255,255,255,0.05); display: flex;
    justify-content: center; align-items: center;
}
canvas { width: 100%; height: auto; }

/* Section Titles */
.section-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent);
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(74, 144, 226, 0.2);
    padding-bottom: 4px;
}

/* Headers & Info Button */
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.ui-card h2 { margin: 0; font-size: 1.1rem; font-weight: 700; }
.icon-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--text-muted);
    width: 24px; height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.8rem;
    display: flex; justify-content: center; align-items: center;
}
.icon-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }

.subtitle { margin: 0 0 20px 0; font-size: 0.85rem; color: var(--text-muted); }

/* Controls */
.control-group { margin-bottom: 20px; }
.label-row { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 0.85rem; color: var(--text-muted); }
.value-tag { background: rgba(255,255,255,0.1); padding: 2px 6px; border-radius: 4px; font-family: monospace; color: var(--accent); }

input[type="range"] {
    width: 100%; height: 4px; background: rgba(255,255,255,0.2); border-radius: 2px;
    appearance: none; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 2px solid #fff;
}

/* Stats Grid */
.stats-grid {
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 20px;
}
.stat-item {
    background: rgba(0,0,0,0.2); padding: 12px; border-radius: 12px;
    display: flex; flex-direction: column;
}
.stat-label { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 4px; }
.stat-value { font-family: 'Courier New', monospace; font-size: 0.9rem; font-weight: 600; }

/* Buttons */
.button-group { display: flex; gap: 12px; margin-bottom: 10px; }
.btn {
    flex: 1; padding: 12px; border: none; border-radius: 10px;
    font-size: 0.85rem; font-weight: 600; cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: rgba(255,255,255,0.1); color: white; }
.btn-secondary:hover { background: rgba(255,255,255,0.15); }

#debug-log {
    margin-top: 16px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.05);
    font-size: 0.75rem; color: #4fe24a;
}

/* --- MODAL STYLES --- */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: flex; justify-content: center; align-items: center;
    opacity: 1; transition: opacity 0.3s;
}
.modal.hidden { opacity: 0; pointer-events: none; }

.modal-content {
    background: #1e1e23;
    width: 90%; max-width: 500px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    overflow: hidden;
}

.modal-header {
    padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h2 { margin: 0; font-size: 1.2rem; }

.modal-body { padding: 20px; max-height: 60vh; overflow-y: auto; }

.concept-block { margin-bottom: 20px; }
.concept-block h3 { margin: 0 0 8px 0; font-size: 1rem; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.concept-block p { margin: 0; font-size: 0.9rem; line-height: 1.5; color: #ccc; }

@media (max-width: 600px) {
    .ui-card {
        top: auto; bottom: 20px; left: 50%;
        transform: translateX(-50%); width: 90%; max-height: 40vh;
    }
}