:root {
    --bg: #020617;
    --panel: rgba(15, 23, 42, 0.75);
    --border: rgba(255, 255, 255, 0.07);
    --primary: #22d3ee;
    --secondary: #a855f7;
    --text: #f8fafc;
    --muted: #64748b;
}

#phet-stage {
    position: absolute;
    top: 0;
    left: 0;
    width: 1280px;
    height: 720px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #020617;
    transform-origin: top left;
}

body.sim-page {
    font-family: 'Outfit', sans-serif;
    color: var(--text);
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #020617;
}

.cg-nav {
    position: relative !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 1.5rem;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 200;
}

.phet-theme {
    font-family: inherit;
}

nav {
    position: absolute !important;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
}

#sim-app {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-top: 60px;
    height: calc(100% - 60px);
}

/* Tab Switcher Styles */
.tab-scroller {
    background: rgba(15, 23, 42, 0.6);
    padding: 12px 0;
    display: flex;
    justify-content: center;
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

.tabs-container {
    display: flex;
    gap: 8px;
    background: #020617;
    padding: 6px;
    border-radius: 14px;
    border: 1px solid var(--border);
}

.tab-btn {
    padding: 10px 25px;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.tab-btn i {
    font-size: 0.9rem;
}

.tab-btn:hover {
    color: #f8fafc;
}

.tab-btn.active {
    background: #2563eb;
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.sim-container {
    display: flex;
    flex: 1;
    width: 100%;
    overflow: hidden;
}

/* Graphing Viewport */
.graph-viewport {
    flex: 1;
    background: #f0f7ff;
    /* PhET-style light blue background */
    padding: 30px;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    touch-action: pan-y;
}

#graphs-stack {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 800px;
    /* Reduced width for better worksheet fit */
    height: fit-content;
    margin: auto 0;
    /* Center vertically in viewport */
}

.graph-container {
    width: 100%;
    height: 180px;
    /* Shorter graphs for 'smaller' requirement */
    position: relative;
    border: 2px solid #555;
    background: #ffffff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.graph-container canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: pointer;
}

.graph-label {
    position: absolute;
    top: 8px;
    left: 8px;
    background: transparent;
    padding: 0;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    font-style: italic;
    font-size: 1.2rem;
    pointer-events: none;
    z-index: 5;
}

#graph-fx .graph-label {
    color: #2563eb;
}

#graph-derivative .graph-label {
    color: #ef4444;
}

#graph-integral .graph-label {
    color: #f59e0b;
}

/* Dark Sidebar */
.dark-aside {
    width: 320px;
    background: var(--panel);
    backdrop-filter: blur(16px);
    border-left: 1px solid var(--border);
    padding: 1.5rem;
    overflow-y: auto;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    touch-action: pan-y;
    z-index: 100;
}

.phet-box {
    background: rgba(30, 41, 59, 0.7);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(5px);
}

.section-header {
    font-size: 0.85rem;
    margin-bottom: 12px;
    color: #cbd5e1;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 8px;
}

.control-hint {
    font-size: 0.85rem;
    color: #94a3b8;
    line-height: 1.5;
    margin-bottom: 15px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: #e2e8f0;
    cursor: pointer;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.info-box h4 {
    color: #3b82f6;
    margin-bottom: 8px;
    font-family: 'Outfit', sans-serif;
}

.info-box p {
    font-size: 0.85rem;
    color: #94a3b8;
    line-height: 1.4;
}

.help-box {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9rem;
}

.help-box p {
    margin-bottom: 5px;
}

/* Curve Selector Panel Styles */
.curve-selector-box {
    background: rgba(15, 23, 42, 0.5) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
}

.curve-parameter {
    margin-bottom: 20px;
    padding: 0 10px;
}

.curve-parameter input[type="range"] {
    width: 100%;
    height: 6px;
    background: #cbd5e1;
    border-radius: 5px;
    appearance: none;
    outline: none;
}

.curve-parameter input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 35px;
    background: #0ea5e9;
    border: 2px solid #075985;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.slider-ticks {
    display: flex;
    justify-content: space-between;
    padding: 0 5px;
    margin-top: 5px;
}

.slider-ticks span {
    width: 1px;
    height: 10px;
    background: #94a3b8;
}

.curve-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.curve-btn {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.curve-btn svg {
    width: 90%;
    height: 90%;
    stroke: var(--text);
    stroke-width: 2.5;
}

.curve-btn:hover {
    background: rgba(30, 41, 59, 0.7);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.curve-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(34, 211, 238, 0.3);
}

.curve-btn.active svg {
    stroke: #020617;
}

.curve-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.yellow-btn {
    background: #fbbf24 !important;
    background: linear-gradient(to bottom, #fde68a, #fbbf24) !important;
    border: 1px solid #d97706 !important;
    color: #000 !important;
    font-weight: 700 !important;
    padding: 10px 40px !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

.action-row {
    display: flex;
    gap: 15px;
}

.btn-utility {
    background: #fbbf24 !important;
    background: linear-gradient(to bottom, #fde68a, #fbbf24) !important;
    border: 1px solid #d97706 !important;
    padding: 8px 15px !important;
    border-radius: 6px !important;
}

.btn-utility i {
    color: #000;
    font-size: 1.2rem;
}

/* Scrollbar */
.dark-aside::-webkit-scrollbar {
    width: 6px;
}

.dark-aside::-webkit-scrollbar-track {
    background: transparent;
}

.dark-aside::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 10px;
}