/* Scoped Variables to prevent bleeding */
.refraction-app-container { 
    --billy-orange: #F5A623; 
    --billy-dark: #333; 
    --billy-blue: #008080; 
    --bg-light: #f9f9f9; 
    --slate-200: #e2e8f0;
    --slate-500: #64748b;
    --slate-800: #1e293b;
    font-family: 'Segoe UI', 'Microsoft JhengHei', sans-serif;
    -webkit-font-smoothing: antialiased;
    width: 100%;
    margin: 0 auto;
}

.refraction-app-container * { 
    box-sizing: border-box; 
}

#billy-notes-wrapper {
    line-height: 1.6; 
    color: #333; 
    width: 100%; 
    max-width: 1100px; 
    margin: 0 auto; 
    padding: 20px; 
    background: #fff;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
    border-radius: 12px;
}

.app-header h2 { 
    color: var(--billy-blue); 
    border-bottom: 3px solid var(--billy-orange); 
    padding-bottom: 10px; 
    font-size: 1.8em; 
    text-align: center; 
    margin-bottom: 20px; 
    margin-top: 0; 
    font-weight: bold;
}

.en-text { font-weight: bold; color: #222; }
.zh-text { color: #666; font-size: 0.9em; display: block; margin-top: 4px; font-weight: normal; }
.zh-inline { color: #666; font-size: 0.85em; font-weight: normal; }

.note-card { 
    background: var(--bg-light); 
    border-radius: 12px; 
    padding: 20px; 
    margin: 20px 0; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05); 
    border-top: 4px solid var(--billy-blue); 
}

.controls-panel {
    background: #fff;
    border: 1px solid var(--slate-200);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
    padding: 15px;
}

.panel-header {
    color: var(--billy-blue);
    font-weight: bold;
    border-bottom: 2px solid var(--slate-200);
    padding-bottom: 8px;
    margin-bottom: 15px;
}

/* Canvas & Layout Shift Prevention */
#refractionCanvas {
    touch-action: none;
    border-radius: 8px;
    display: block;
}

.diagram-container {
    position: relative;
    width: 100%;
    background: #0f172a; 
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--slate-200);
    min-height: 500px; /* Prevents layout shift */
}

/* Sliders */
.refraction-app-container input[type=range] {
    -webkit-appearance: none; 
    width: 100%; 
    background: transparent; 
}
.refraction-app-container 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;
}
.refraction-app-container input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: var(--slate-200);
    border-radius: 3px;
}

/* Buttons */
.btn-start {
    background: linear-gradient(135deg, #F5A623 0%, #F76B1C 100%);
    color: white;
    box-shadow: 0 4px 10px rgba(245, 166, 35, 0.3);
    border: none;
    font-weight: bold;
    transition: all 0.2s;
}
.btn-start.active-light {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    box-shadow: 0 4px 10px rgba(34, 197, 94, 0.3);
}
.btn-start:hover { transform: translateY(-2px); box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15); }
.btn-start:active { transform: scale(0.98); }

.btn-reset {
    background: white;
    border: 2px solid var(--billy-blue);
    color: var(--billy-blue);
    font-weight: bold;
    transition: all 0.2s;
}
.btn-reset:hover { background: #f0f8f8; transform: translateY(-2px); }
.btn-reset:active { transform: scale(0.98); }

/* Info Box */
.info-box {
    padding: 20px;
    background: #fffbf0;
    border-left: 5px solid var(--billy-orange);
    border-radius: 0 8px 8px 0;
    color: #333;
    font-size: 0.95rem;
}

/* Mobile Optimization */
@media (max-width: 600px) {
    #billy-notes-wrapper { padding: 12px; }
    .note-card { padding: 15px; }
    .diagram-container { min-height: 400px; }
    #refractionCanvas { height: 400px; }
}