* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

.background-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background-color: #000;
    overflow: hidden;
}

#apodImage {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    object-position: center;
    opacity: 0;
    transition: opacity 0.5s ease-in, object-fit 0.3s ease, object-position 0.3s ease;
    display: block;
    margin: 0;
    padding: 0;
}

#apodImage.loaded {
    opacity: 1;
}

.overlay {
    position: relative;
    z-index: 10;
    pointer-events: none;
}

/* Settings Toggle Button */
.settings-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    z-index: 30;
    transition: all 0.2s ease;
    padding: 0;
    margin: 0;
}

.settings-toggle:hover {
    background: rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 1);
}

.settings-toggle i {
    display: block;
    line-height: 1;
    font-style: normal;
    font-variant: normal;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 320px;
    max-height: calc(100vh - 40px);
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: white;
    pointer-events: auto;
    z-index: 31;
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
    visibility: hidden;
    transition: all 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.settings-panel.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.settings-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.settings-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 1);
}

.settings-close i {
    font-weight: 400;
    font-size: 14px;
}

.settings-content {
    padding: 12px 20px 20px;
    overflow-y: auto;
    max-height: calc(100vh - 120px);
}

.settings-item {
    margin-bottom: 16px;
}

.settings-item:last-child {
    margin-bottom: 0;
}

.settings-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    user-select: none;
}

.settings-label i {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.7);
    width: 20px;
    text-align: center;
    font-weight: 400;
}

.settings-label span:not(.settings-toggle-switch) {
    flex: 1;
}

.settings-checkbox {
    display: none;
}

.settings-toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.settings-toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.settings-checkbox:checked + .settings-toggle-switch {
    background: rgba(74, 158, 255, 0.6);
}

.settings-checkbox:checked + .settings-toggle-switch::after {
    transform: translateX(20px);
}

.settings-select {
    width: 100%;
    margin-top: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.settings-select:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.settings-select:focus {
    border-color: rgba(74, 158, 255, 0.5);
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}

.settings-select option {
    background: #1a1a1a;
    color: white;
}

.settings-link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 14px;
    padding: 8px 0;
    transition: color 0.2s ease;
}

.settings-link:hover {
    color: rgba(255, 255, 255, 0.9);
}

.settings-link i {
    font-size: 16px;
    font-weight: 400;
    width: 20px;
    text-align: center;
}

.dimensions-overlay {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 12px 16px;
    pointer-events: auto;
    z-index: 25;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    color: white;
    line-height: 1.6;
    min-width: 200px;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.dimensions-overlay.hidden {
    opacity: 0;
    transform: translateX(-10px);
    pointer-events: none;
}

/* Old dimensions toggle/close - now in settings */
.dimensions-toggle,
.dimensions-close {
    display: none;
}

.dimension-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.dimension-item:last-child {
    margin-bottom: 0;
}

.dimension-label {
    color: #aaa;
    margin-right: 12px;
}

#viewportDimensions,
#imageDimensions,
#scaleInfo,
#displayMode {
    color: #4a9eff;
    font-weight: 600;
}

/* Old source selector - now in settings */
.source-selector {
    display: none;
}

/* Old source-link - now in settings panel */
.source-link {
    display: none;
}

#sourceSelect {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 10px 15px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s ease, border-color 0.3s ease;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='white' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 35px;
}

#sourceSelect:hover {
    background-color: rgba(0, 0, 0, 0.85);
    border-color: rgba(255, 255, 255, 0.3);
}

#sourceSelect:focus {
    border-color: #4a9eff;
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}

.bing-picture-select {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 10px 15px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s ease, border-color 0.3s ease, opacity 0.3s ease;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='white' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 35px;
    min-width: 250px;
    max-width: 400px;
}

.bing-picture-select.hidden {
    display: none;
}

.bing-picture-select:hover {
    background-color: rgba(0, 0, 0, 0.85);
    border-color: rgba(255, 255, 255, 0.3);
}

.bing-picture-select:focus {
    border-color: #4a9eff;
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}

.bing-picture-select option {
    background: #1a1a1a;
    color: white;
    padding: 8px;
}

/* Old info toggle - now in settings */
.info-toggle {
    display: none;
}

.info-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.7) 70%, rgba(0, 0, 0, 0) 100%);
    backdrop-filter: blur(20px);
    color: white;
    padding: 20px 40px 20px 40px;
    padding-top: 30px;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: auto;
    max-height: 50vh;
    min-height: auto;
    height: auto;
    overflow-y: auto;
    box-sizing: border-box;
    transform: translateY(0);
    opacity: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.info-panel.hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

/* Old info close - now in settings */
.info-close {
    display: none;
}

.info-content {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.info-content h1 {
    font-size: 28px;
    margin-bottom: 6px;
    font-weight: 700;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
    line-height: 1.2;
    width: 100%;
    max-width: 100%;
    text-align: left;
}

.info-content p {
    margin-bottom: 8px;
    line-height: 1.4;
    font-size: 15px;
    text-shadow: 0 1px 5px rgba(0, 0, 0, 0.6);
    width: 100%;
    max-width: 100%;
}

/* Responsive styles for mobile and small viewports */
@media (max-width: 768px) {
    .info-panel {
        max-height: 40vh;
        padding: 15px 20px 15px 20px;
        padding-top: 20px;
    }
    
    .info-content h1 {
        font-size: 20px;
        margin-bottom: 4px;
        line-height: 1.3;
    }
    
    .info-content p {
        font-size: 13px;
        margin-bottom: 6px;
        line-height: 1.4;
    }
    
    .info-content #apodDate {
        font-size: 11px;
        margin-bottom: 6px;
    }
    
    .info-content #apodDescription {
        font-size: 13px;
        line-height: 1.4;
        margin-bottom: 6px;
    }
    
    .info-content .copyright {
        font-size: 11px;
        margin-top: 6px;
        margin-bottom: 6px;
    }
}

@media (max-width: 480px) {
    .info-panel {
        max-height: 35vh;
        padding: 12px 16px 12px 16px;
        padding-top: 16px;
    }
    
    .info-content h1 {
        font-size: 18px;
        margin-bottom: 3px;
        line-height: 1.3;
    }
    
    .info-content p {
        font-size: 12px;
        margin-bottom: 5px;
        line-height: 1.35;
    }
    
    .info-content #apodDate {
        font-size: 10px;
        margin-bottom: 5px;
    }
    
    .info-content #apodDescription {
        font-size: 12px;
        line-height: 1.35;
        margin-bottom: 5px;
    }
    
    .info-content .copyright {
        font-size: 10px;
        margin-top: 5px;
        margin-bottom: 5px;
    }
}

.info-content #apodDate {
    color: #ccc;
    font-size: 13px;
    font-weight: 500;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    margin-bottom: 8px;
    width: 100%;
    max-width: 100%;
}

.info-content #apodDescription {
    max-width: 100%;
    width: 100%;
    font-size: 15px;
    line-height: 1.4;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
    margin-bottom: 8px;
}

.info-content #apodDescription a {
    color: #4a9eff;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.info-content #apodDescription a:hover {
    color: #6bb3ff;
    text-decoration: underline;
}

.info-content .copyright {
    font-size: 13px;
    color: #bbb;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    margin-top: 8px;
    margin-bottom: 8px;
    width: 100%;
    max-width: 100%;
}


.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 100;
    transition: opacity 0.3s ease;
}

.loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading p {
    font-size: 16px;
}
