* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: #fff;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    background: linear-gradient(90deg, #00d9ff, #00ff88);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 5px;
}

header p {
    color: #8892b0;
    font-size: 1.1rem;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

/* Search Section */
.search-section {
    width: 100%;
    max-width: 500px;
    position: relative;
}

.search-box {
    display: flex;
    gap: 10px;
}

#molecule-search {
    flex: 1;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid #3a3a5a;
    border-radius: 10px;
    background: #2a2a4a;
    color: #fff;
    transition: border-color 0.3s;
}

#molecule-search:focus {
    outline: none;
    border-color: #00d9ff;
}

#molecule-search::placeholder {
    color: #6a6a8a;
}

#search-btn {
    padding: 12px 24px;
    font-size: 1rem;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #00d9ff, #00ff88);
    color: #1a1a2e;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

#search-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 217, 255, 0.4);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #2a2a4a;
    border-radius: 10px;
    margin-top: 5px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.search-results.visible {
    display: block;
}

.search-result-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #3a3a5a;
    transition: background 0.2s;
}

.search-result-item:hover {
    background: #3a3a6a;
}

.search-result-item:last-child {
    border-bottom: none;
}

/* Quick Select */
.quick-select {
    display: flex;
    align-items: center;
    gap: 10px;
}

.quick-select label {
    font-weight: 600;
    color: #8892b0;
}

#molecule-select {
    padding: 10px 15px;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    background: #2a2a4a;
    color: #fff;
    cursor: pointer;
    min-width: 180px;
}

#molecule-select:focus {
    outline: 2px solid #00d9ff;
}

#molecule-select optgroup {
    background: #2a2a4a;
    color: #00d9ff;
}

#molecule-select option {
    background: #1a1a2e;
    color: #fff;
    padding: 5px;
}

.view-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.view-btn {
    padding: 8px 16px;
    border: 2px solid #00d9ff;
    background: transparent;
    color: #00d9ff;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.view-btn:hover {
    background: rgba(0, 217, 255, 0.2);
}

.view-btn.active {
    background: #00d9ff;
    color: #1a1a2e;
}

.rotation-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.rotation-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

#rotation-speed {
    width: 80px;
    cursor: pointer;
}


.viewer-container {
    display: flex;
    gap: 30px;
    justify-content: center;
    flex-wrap: wrap;
}

.main-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.molecule-viewer {
    width: 600px;
    height: 500px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    position: relative;
}

.molecule-viewer canvas {
    border-radius: 20px;
}

.info-panel {
    width: 300px;
    padding: 25px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.info-panel h3 {
    font-size: 1.8rem;
    margin-bottom: 10px;
    color: #00d9ff;
}

.formula {
    font-size: 1.4rem;
    margin-bottom: 20px;
    font-family: 'Times New Roman', serif;
    color: #00ff88;
}

.info-text {
    line-height: 1.6;
    color: #b8c5d6;
    margin-bottom: 25px;
}

.legend {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
}

.legend h4 {
    margin-bottom: 15px;
    color: #8892b0;
}

/* Properties Grid */
.properties-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 15px;
    margin-bottom: 15px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    font-size: 0.85rem;
}

.properties-grid:empty {
    display: none;
}

.prop-item {
    display: flex;
    flex-direction: column;
}

.prop-label {
    color: #6a7a8a;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.prop-value {
    color: #fff;
    font-weight: 500;
}

.prop-value.charge-positive {
    color: #ff6666;
}

.prop-value.charge-negative {
    color: #66aaff;
}

/* SMILES box */
.smiles-box {
    margin-bottom: 15px;
}

.smiles-box:empty {
    display: none;
}

.smiles-label {
    color: #6a7a8a;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.smiles-value {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: #00ff88;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px;
    border-radius: 6px;
    word-break: break-all;
    max-height: 60px;
    overflow-y: auto;
}

/* Lewis Structure Section */
.lewis-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.lewis-section h4 {
    color: #00d9ff;
    margin-bottom: 15px;
    font-size: 1.1rem;
    text-align: center;
}

.lewis-container {
    text-align: center;
}

#lewis-canvas {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 100%;
}

.lewis-hint {
    font-size: 0.8rem;
    color: #8892b0;
    margin-top: 10px;
}

/* Legend as collapsible */
.legend-details {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 10px;
}

.legend-details summary {
    cursor: pointer;
    color: #8892b0;
    font-size: 0.9rem;
    padding: 5px 0;
}

.legend-details summary:hover {
    color: #00d9ff;
}

.legend {
    padding-top: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.atom-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: inset -3px -3px 8px rgba(0, 0, 0, 0.3),
                inset 3px 3px 8px rgba(255, 255, 255, 0.2);
}

.atom-color.carbon {
    background: radial-gradient(circle at 30% 30%, #666, #333);
}

.atom-color.hydrogen {
    background: radial-gradient(circle at 30% 30%, #fff, #ccc);
}

.atom-color.oxygen {
    background: radial-gradient(circle at 30% 30%, #ff6666, #cc0000);
}

.atom-color.nitrogen {
    background: radial-gradient(circle at 30% 30%, #6666ff, #0000cc);
}

.atom-color.sulfur {
    background: radial-gradient(circle at 30% 30%, #ffff66, #cccc00);
}

.atom-color.phosphorus {
    background: radial-gradient(circle at 30% 30%, #ff9933, #cc6600);
}

.atom-color.halogen {
    background: radial-gradient(circle at 30% 30%, #33ff33, #00aa00);
}

/* Loading Spinner */
.loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 26, 46, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    border-radius: 20px;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #3a3a5a;
    border-top-color: #00d9ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    margin-top: 15px;
    color: #8892b0;
}

/* Molecule Links */
.molecule-links {
    margin-bottom: 20px;
}

.molecule-links a {
    color: #00d9ff;
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.molecule-links a:hover {
    color: #00ff88;
}

/* Molecular Weight */
.weight {
    font-size: 0.95rem;
    color: #8892b0;
    margin-bottom: 15px;
}

/* Info text formatting */
.info-text {
    white-space: pre-line;
}

/* 3D Molecule Elements */
.atom {
    position: absolute;
    border-radius: 50%;
    transform-style: preserve-3d;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.atom:hover {
    transform: scale(1.1);
}

.atom.carbon {
    background: radial-gradient(circle at 30% 30%, #888, #333);
    box-shadow: inset -5px -5px 15px rgba(0, 0, 0, 0.5),
                inset 5px 5px 15px rgba(255, 255, 255, 0.1),
                0 0 20px rgba(100, 100, 100, 0.3);
}

.atom.hydrogen {
    background: radial-gradient(circle at 30% 30%, #ffffff, #aaaaaa);
    box-shadow: inset -3px -3px 10px rgba(0, 0, 0, 0.2),
                inset 3px 3px 10px rgba(255, 255, 255, 0.5),
                0 0 15px rgba(255, 255, 255, 0.2);
}

.atom.oxygen {
    background: radial-gradient(circle at 30% 30%, #ff4444, #aa0000);
    box-shadow: inset -5px -5px 15px rgba(0, 0, 0, 0.4),
                inset 5px 5px 15px rgba(255, 100, 100, 0.3),
                0 0 20px rgba(255, 0, 0, 0.3);
}

.atom.nitrogen {
    background: radial-gradient(circle at 30% 30%, #4444ff, #0000aa);
    box-shadow: inset -5px -5px 15px rgba(0, 0, 0, 0.4),
                inset 5px 5px 15px rgba(100, 100, 255, 0.3),
                0 0 20px rgba(0, 0, 255, 0.3);
}

.bond {
    position: absolute;
    background: linear-gradient(90deg, #666, #888, #666);
    transform-origin: left center;
    transform-style: preserve-3d;
    border-radius: 3px;
}

.bond.double {
    background: linear-gradient(90deg,
        transparent 0%, transparent 35%,
        #666 35%, #888 50%, #666 65%,
        transparent 65%, transparent 100%
    );
}

.bond.triple {
    background: linear-gradient(90deg,
        transparent 0%, transparent 25%,
        #666 25%, #888 30%, #666 35%,
        transparent 35%, transparent 45%,
        #666 45%, #888 50%, #666 55%,
        transparent 55%, transparent 65%,
        #666 65%, #888 70%, #666 75%,
        transparent 75%, transparent 100%
    );
}

.instructions {
    text-align: center;
    margin-top: 30px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    color: #8892b0;
}

/* Space filling mode */
.space-fill .atom {
    opacity: 0.9;
}

.space-fill .bond {
    display: none;
}

/* Stick only mode */
.stick .atom {
    width: 10px !important;
    height: 10px !important;
}

/* Footer */
.site-footer {
    margin-top: 40px;
    padding: 30px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-content {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
    justify-content: space-between;
}

.footer-section {
    flex: 1;
    min-width: 200px;
}

.footer-section h4 {
    color: #00d9ff;
    font-size: 1.1rem;
    margin-bottom: 15px;
}

.footer-section p {
    color: #8892b0;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 15px;
}

.footer-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #8892b0;
    text-decoration: none;
    font-size: 0.95rem;
    padding: 8px 0;
    transition: color 0.2s;
}

.footer-link:hover {
    color: #00d9ff;
}

.footer-link svg {
    flex-shrink: 0;
}

/* Support Section */
.support-section {
    background: rgba(139, 69, 69, 0.2);
    border: 1px solid rgba(139, 69, 69, 0.4);
    border-radius: 12px;
    padding: 20px;
    max-width: 280px;
}

.coffee-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #ff813f;
    color: #fff;
    text-decoration: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.coffee-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(255, 129, 63, 0.4);
}

.coffee-btn svg {
    flex-shrink: 0;
}

/* Footer Attribution */
.footer-attribution {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
}

.footer-attribution p {
    color: #6a7a8a;
    font-size: 0.85rem;
    margin-bottom: 5px;
}

.footer-attribution a {
    color: #8892b0;
    text-decoration: none;
    transition: color 0.2s;
}

.footer-attribution a:hover {
    color: #00d9ff;
}

/* Responsive */
@media (max-width: 768px) {
    .viewer-container {
        flex-direction: column;
        align-items: center;
    }

    .main-column {
        width: 100%;
        max-width: 400px;
    }

    .molecule-viewer {
        width: 100%;
        max-width: 400px;
        height: 400px;
    }

    #lewis-canvas {
        width: 100%;
        height: auto;
    }

    .info-panel {
        width: 100%;
        max-width: 400px;
    }

    .controls {
        flex-direction: column;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .footer-content {
        flex-direction: column;
        gap: 30px;
    }

    .footer-section {
        min-width: unset;
    }

    .support-section {
        max-width: 100%;
    }
}
