/* Base Reset & Variables */
html, body { 
    margin: 0; 
    padding: 0; 
    width: 100%; 
    background: #f4f7f6; 
    font-family: 'Segoe UI', 'Microsoft JhengHei', sans-serif;
    -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }

:root { 
    --billy-orange: #F5A623; 
    --billy-dark: #333; 
    --billy-blue: #008080; 
    --bg-light: #f9f9f9; 
    --slate-200: #e2e8f0;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-800: #1e293b;
    --indigo-500: #6366f1;
    --cyan-600: #0891b2;
}

#billy-notes-wrapper {
    line-height: 1.6; 
    color: #333; 
    width: 100%; 
    max-width: 900px;
    margin: 0 auto; 
    padding: 20px; 
    background: #fff;
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
}

/* Typography */
#billy-notes-wrapper h1 { 
    color: var(--billy-blue); 
    border-bottom: 3px solid var(--billy-orange); 
    padding-bottom: 10px; 
    font-size: 2em; 
    text-align: center; 
    margin-bottom: 20px; 
    margin-top: 0; 
}
.zh-text { color: #666; font-size: 0.9em; display: block; margin-top: 4px; font-weight: normal; }

/* Cards & Layout */
.note-card { 
    background: var(--bg-light); 
    border-radius: 12px; 
    padding: 0; 
    margin: 20px 0; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05); 
    border-top: 4px solid var(--billy-blue); 
    overflow: hidden;
}

.card-header {
    padding: 15px 25px;
    border-bottom: 1px solid var(--slate-200);
    display: flex;
    align-items: center;
    background: #fff;
    gap: 15px;
    font-size: 1.1rem; 
    font-weight: bold; 
    color: var(--slate-800);
}

/* Diagram Area */
.diagram-container {
    width: 100%;
    background: #0f172a;
    border-bottom: 1px solid var(--slate-200);
    padding: 20px;
}
#sim-wrapper {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    box-sizing: border-box;
}
canvas#sim-canvas {
    display: block;
    width: 100%;
    height: 250px;
    image-rendering: pixelated;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}
.overlay-info {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85rem;
    pointer-events: none;
    z-index: 10;
}

/* Chart Area */
.chart-container {
    padding: 20px;
    background: #fff;
    height: 250px;
    width: 100%;
    border-bottom: 1px solid var(--slate-200);
}

/* Sliders & Controls */
.sliders-wrapper {
    padding: 25px;
    background: #fff;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.slider-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 0.9rem;
    color: var(--slate-800);
}
.val-badge {
    background: var(--bg-light);
    border: 1px solid var(--slate-200);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--billy-blue);
}

input[type=range] {
    -webkit-appearance: none; 
    width: 100%; 
    background: transparent; 
    margin: 8px 0;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: var(--billy-blue);
    cursor: pointer;
    margin-top: -6px; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    border: 2px solid white;
}
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: var(--slate-200);
    border-radius: 3px;
}
.spectrum-bar {
    height: 8px;
    width: 100%;
    border-radius: 4px;
    background: linear-gradient(to right, #7c3aed, #10b981, #ef4444);
    margin-top: -4px;
    opacity: 0.8;
}

/* Toggle Buttons */
.toggle-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}
.toggle-btn {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid var(--slate-200);
    background: var(--bg-light);
    color: var(--slate-500);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.toggle-btn.active {
    background: #eff6ff;
    color: var(--cyan-600);
    border-color: #bfdbfe;
}

/* Info Box */
.info-box {
    margin: 0 25px 25px 25px;
    padding: 20px;
    background: #fffbf0;
    border-left: 5px solid var(--billy-orange);
    border-radius: 0 8px 8px 0;
    color: #333;
    font-size: 0.95rem;
}
.math-container {
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--slate-200);
    margin: 15px 0;
    overflow-x: auto;
    text-align: center;
}

/* Collapsible details styling */
details summary {
    cursor: pointer;
    outline: none;
    user-select: none;
}
details summary::-webkit-details-marker {
    color: var(--billy-blue);
}

@media (max-width: 768px) {
    .sliders-wrapper { grid-template-columns: 1fr; }
}