/* 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;
    overflow-x: hidden;
}
* { box-sizing: border-box; }

:root { 
    --billy-orange: #F5A623; 
    --billy-dark: #333; 
    --billy-blue: #008080; 
    --bg-light: #f9f9f9; 
    --slate-200: #e2e8f0;
    --slate-500: #64748b;
    --slate-800: #1e293b;
    --slate-900: #0f172a;
    --blue-500: #3b82f6;
    --green-500: #22c55e;
}

#billy-notes-wrapper {
    line-height: 1.6; 
    color: #333; 
    width: 100%; 
    max-width: 800px;
    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: 20px 25px;
    border-bottom: 1px solid var(--slate-200);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #fff;
    gap: 15px;
}

/* Diagram Area */
.diagram-container {
    position: relative;
    width: 100%;
    background: var(--slate-900);
    border-bottom: 1px solid var(--slate-200);
    padding: 0;
    line-height: 0;
    aspect-ratio: 4/3;
    max-height: 450px;
    overflow: hidden;
}

@media (min-width: 640px) {
    .diagram-container {
        aspect-ratio: 16/9;
    }
}

/* Controls */
.controls-wrapper {
    padding: 20px 25px;
    background: #fff;
    border-bottom: 1px solid var(--slate-200);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.compound-btn {
    padding: 8px 16px;
    border-radius: 9999px;
    font-weight: bold;
    transition: all 0.2s;
    border: 2px solid transparent;
    cursor: pointer;
}
.compound-btn.active {
    background: var(--billy-blue);
    color: white;
    box-shadow: 0 4px 10px rgba(0, 128, 128, 0.3);
}
.compound-btn.inactive {
    background: var(--slate-200);
    color: var(--slate-500);
}
.compound-btn.inactive:hover {
    background: var(--slate-800);
    color: white;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: bold;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
}
.action-btn-primary {
    background: var(--blue-500);
    color: white;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}
.action-btn-primary:active { transform: scale(0.95); }
.action-btn-reset {
    background: white;
    border: 2px solid var(--slate-500);
    color: var(--slate-600);
}
.action-btn-reset:active { transform: scale(0.95); }

/* Info Box */
.info-box {
    margin: 25px;
    padding: 20px;
    background: #fffbf0;
    border-left: 5px solid var(--billy-orange);
    border-radius: 0 8px 8px 0;
    color: #333;
    font-size: 0.95rem;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.no-select { user-select: none; -webkit-user-select: none; }

/* Animation Classes */
.anim-element {
    /* FIX 1: Added 'left' and 'top' to the transition so the electron glides smoothly */
    transition: transform 0.8s ease-in-out, opacity 0.5s ease-in-out, left 0.8s ease-in-out, top 0.8s ease-in-out;
    position: absolute;
    transform: translate(-50%, -50%);
}
.charge-badge {
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: scale(0);
}
.charge-badge.show {
    transform: scale(1);
}
.lattice-ion {
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.5s;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
}
.lattice-ion.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}