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

/* Z-Index Tiers */
:root {
    --z-index-sidebar: 1000;
    --z-index-first-click: 9999;
    --z-index-preloader: 10001;
    --z-index-error: 10002;
}

/* Body Styles */
.app-body {
    background-color: var(--color-background, #1a1a1a);
    color: var(--color-text, #ffffff);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: row;
    min-height: 100vh;
    overflow: hidden;
}

/* Sidebar Styles */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    background: linear-gradient(to right, 
        color-mix(in srgb, var(--color-surface, #2a2a2a) 95%, transparent),
        color-mix(in srgb, var(--color-surface, #2a2a2a) 85%, transparent));
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    z-index: var(--z-index-sidebar);
    backdrop-filter: blur(10px);
}

/* Canvas Container Styles */
.app-canvas-container {
    position: fixed;
    top: 0;
    left: 300px;
    right: 0;
    bottom: 0;
}

/* Scene Wrapper Styles */
#scene-wrapper {
    position: absolute;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
}

/* Canvas Styles */
#three-d-canvas {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    background-color: var(--color-background);
    display: block;
    flex-shrink: 0;
}


.control-select {
    background-color: var(--color-surface);
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    min-width: 120px;
}
/* Display Range Styles */
.display-range-options {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin: 10px 0;
}

.display-range-option {
    flex: 1;
    cursor: pointer;
    position: relative;
}

.display-range-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.display-range-icon {
    width: 100%;
    height: auto;
    display: block;
    padding: 8px;
    border: 2px solid transparent;
    border-radius: 8px;
    background-color: var(--color-surface);
    transition: all 0.2s ease;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
    mask-type: alpha;
}

.display-range-option input[type="radio"]:checked + .display-range-icon {
    border-color: var(--color-primary);
    background-color: color-mix(in srgb, var(--color-primary) 15%, var(--color-surface));
}

.display-range-option:hover .display-range-icon {
    background-color: color-mix(in srgb, var(--color-primary) 8%, var(--color-surface));
}






/* Error Message Styles */
.error-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: color-mix(in srgb, var(--color-background) 80%, transparent);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: var(--z-index-error);
}
.error-panel {
    background-color: var(--color-surface);
    color: var(--color-text, #ffffff);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 20px 60px color-mix(in srgb, var(--color-background) 50%, transparent);
    max-width: 600px;
    text-align: center;
}
.error-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--color-error);
}
.error-details {
    font-size: 16px;
    line-height: 1.5;
    color: color-mix(in srgb, var(--color-text, #ffffff) 80%, transparent);
    white-space: pre-wrap;
}

/* First Click Styles */
.first-click-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: color-mix(in srgb, var(--color-background, #1a1a1a) 80%, transparent);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: var(--z-index-first-click);
    cursor: pointer;
}
.first-click-panel {
    background-color: var(--color-surface, #2a2a2a);
    color: var(--color-text, #ffffff);
    padding: 60px;
    border-radius: 16px;
    box-shadow: 0 25px 75px color-mix(in srgb, var(--color-background) 60%, transparent);
    max-width: 600px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.first-click-description {
    font-size: 18px;
    line-height: 1.6;
    color: var(--color-text);
}

/* Component Styles */
.tonal-center-display {
    background-color: color-mix(in srgb, var(--color-primary, #4a9eff) 10%, transparent);
    color: var(--color-primary, #4a9eff);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    min-width: 60px;
    text-align: center;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
}
.small-button {
    background-color: var(--color-surface, #2a2a2a);
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s;
}

.ui-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    padding: 0 12px;
}

/* Section wrapper for visual grouping */
.section-group {
    background: color-mix(in srgb, var(--color-surface, #2a2a2a) 50%, transparent);
    border-radius: 8px;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
}
.volume-display {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 12px;
    color: var(--color-primary);
    min-width: 40px;
    text-align: right;
}
/* The link back to the site. Its form is the site's - small, uppercase,
   letterspaced, quiet until hovered - but its colours and its typeface are this
   app's, because an application keeps its own world and only owes the site a way
   home. The fallbacks matter: the colour variables are injected by the wasm at
   runtime, and this has to be legible before that happens. `:visited` is spelled
   out alongside the base selector so that the way home looks the same whether or
   not it has been used, rather than going the browser's purple. */
.site-masthead,
.site-masthead:visited {
    display: block;
    margin: 0 0 14px 0;
    text-align: center;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 12px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--color-muted, #8a8a8a);
    /* Letter-spacing adds a gap after the last letter too, which throws a
       centred line half that distance to the left. This puts it back. */
    padding-left: 0.2em;
}
.site-masthead:hover,
.site-masthead:focus-visible {
    color: var(--color-text, #ffffff);
    text-decoration: underline;
}

.sidebar-header {
    color: var(--color-text);
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 20px 0;
    padding: 16px 0;
    text-align: center;
    border-bottom: 2px solid var(--color-border);
    font-family: system-ui, -apple-system, sans-serif;
}
.subsection-header {
    color: var(--color-text);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
    margin-top: 0;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

/* About Section Styles */
.about-container {
    border-top: 2px solid var(--color-border);
    padding-top: 16px;
    margin-top: 24px;
}

.about-section {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.about-header {
    color: var(--color-text, #ffffff);
    font-size: 15px;
    font-weight: 600;
    margin-top: 6px;
}
.about-content {
    padding: 16px 8px;
    background-color: color-mix(in srgb, var(--color-surface) 50%, transparent);
    border-radius: 8px;
    overflow-y: auto;
    flex: 1;
}
.about-text {
    color: color-mix(in srgb, var(--color-text) 65%, transparent);
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 12px;
}

/* Range Input Styles */
input[type="range"] {
    width: 100%;
    height: 6px;
    cursor: pointer;
    appearance: none;
    background: color-mix(in srgb, var(--color-muted, #666666) 30%, transparent);
    border-radius: 3px;
    outline: none;
    transition: all 0.2s;
}
input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-primary, #4a9eff);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-primary, #4a9eff);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
input[type="range"]:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary, #4a9eff) 30%, transparent);
}
input[type="range"]:focus::-moz-range-thumb {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary, #4a9eff) 30%, transparent);
}

.first-click-title {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--color-primary);
}


/* Extracted inline styles from index.html */
.control-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tonal-center-controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}


.volume-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.8;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
    mask-type: alpha;
    mask: url("icons/speaker.png") no-repeat center / contain;
    -webkit-mask: url("icons/speaker.png") no-repeat center / contain;
    background-color: var(--color-primary);
}

.volume-icon.clickable {
    cursor: pointer;
    transition: opacity 0.2s;
}

.volume-icon.clickable:hover {
    opacity: 1.0;
}

.volume-icon.muted {
    mask: url("icons/speaker-off.png") no-repeat center / contain;
    -webkit-mask: url("icons/speaker-off.png") no-repeat center / contain;
}

#tonal-center-volume {
    width: 125px;
}


.error-overlay-hidden {
    display: none;
}

.first-click-overlay-hidden {
    display: none;
}

.permission-note {
    opacity: 0.7;
}

/* Help Text Styles */
.help-text {
    font-size: 11px;
    color: color-mix(in srgb, var(--color-text) 65%, transparent);
    line-height: 1.4;
    margin-top: 8px;
    margin-bottom: 0;
    padding: 0;
    background: transparent;
    border-radius: 0;
    border: none;
}


/* Preloader Styles */
.preloader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: color-mix(in srgb, var(--color-background, #1a1a1a) 80%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-index-preloader);
    transition: opacity 0.3s ease;
}


.preloader-content {
    background-color: #2a2a2a;
    color: #ffffff;
    padding: 60px;
    border-radius: 16px;
    box-shadow: 0 25px 75px rgba(0, 0, 0, 0.6);
    max-width: 600px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.preloader-title {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 28px;
    font-weight: 600;
    color: #ffffff;
    margin: 0 0 24px 0;
}

.preloader-spinner {
    width: 32px;
    height: 32px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: preloader-spin 1s linear infinite;
    margin: 8px 0;
}

.preloader-text {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 18px;
    line-height: 1.6;
    color: #cccccc;
    margin: 0;
}

@keyframes preloader-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}