:root {
    --transition-speed: 0.8s;
    --font-heading: 'Playfair Display', serif;
    --font-ui: 'Roboto Mono', monospace;
}

/* --- THEME DEFINITIONS --- */
body.theme-obsidian {
    --bg-color: #0d0d0d;
    --accent-color: #ffffff;
    --plinth-base: #111;
    --plinth-side: #050505;
    --plinth-highlight: rgba(255,255,255,0.03);
    --plinth-shadow: rgba(0,0,0,0.8);
    --knob-main: linear-gradient(145deg, #1a1a1a, #050505);
    --metal-edge: linear-gradient(145deg, #333, #111);
}

body.theme-walnut {
    --bg-color: #120c0a; 
    --accent-color: #c96b3a;
    --plinth-base: #2a1b16; 
    --plinth-side: #1c110e;  
    --plinth-highlight: rgba(255, 159, 67, 0.05);
    --plinth-shadow: rgba(0,0,0,0.9);
    --knob-main: linear-gradient(145deg, #3d2b1f, #1a0f0d);
    --metal-edge: linear-gradient(145deg, #bbb, #555); 
}

body.theme-warm {
    --bg-color: #1a0a05;
    --accent-color: #e26a2c;
    --plinth-base: #4d1a0a;
    --plinth-side: #301005;
    --plinth-highlight: rgba(255, 255, 255, 0.1);
    --plinth-shadow: rgba(0,0,0,0.8);
    --knob-main: linear-gradient(145deg, #b34a17, #5c2307);
    --metal-edge: linear-gradient(145deg, #fff, #e26a2c);
}

body.theme-alabaster {
    --bg-color: #ffffff;
    --accent-color: #3498db;
    --plinth-base: #f0f0f0;
    --plinth-side: #d0d0d0;
    --plinth-highlight: #ffffff;
    --plinth-shadow: rgba(0,0,0,0.15);
    --knob-main: linear-gradient(145deg, #ffffff, #e6e6e6);
    --metal-edge: linear-gradient(145deg, #fff, #bdc3c7);
}

body {
    margin: 0; padding: 0;
    background-color: var(--bg-color);
    font-family: var(--font-ui);
    display: flex; flex-direction: column;
    height: 100vh; overflow: hidden;
    transition: background-color var(--transition-speed);
}

.app-container { display: flex; flex: 1; height: 100%; }
.ad-rail { width: 120px; background: rgba(0,0,0,0.05); display: flex; justify-content: center; padding-top: 20px; opacity: 0.2; }
.main-content { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow-y: auto; }

.header { text-align: center; margin-top: 2vh; z-index: 10; transform: translateZ(50px); }
.logo { font-family: var(--font-heading); font-size: 2.5rem; color: var(--accent-color); margin: 0; font-style: italic; }
.tagline { display: block; margin-top: 12px; font-size: 0.7rem; letter-spacing: 4px; text-transform: uppercase; color: #666; }

/* Theme Selector */
.theme-selector { position: absolute; top: 20px; right: 20px; display: flex; gap: 10px; z-index: 100; transform: translateZ(10px); }
.theme-dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(128,128,128,0.3); cursor: pointer; padding: 0; transition: transform 0.2s; }
.theme-dot:hover { transform: scale(1.2); }
.theme-dot.active { border-color: var(--accent-color); transform: scale(1.2); }
.theme-dot.obsidian { background: #0a0a0a; } .theme-dot.walnut { background: #231512; }
.theme-dot.warm { background: #8d2a1a; } .theme-dot.alabaster { background: #ffffff; }

/* --- 3D TURNTABLE WRAPPER --- */
.turntable-wrapper {
    perspective: 1200px;
    width: 600px;
    height: 500px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
    margin-bottom: 20px;
}

/* The actual wooden base */
.turntable-hero {
    width: 520px;
    height: 400px;
    background: var(--plinth-base);
    border-radius: 6px;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(45deg) rotateZ(0deg);
    /* Front 3D sides using box shadow for thickness (pointing straight down) */
    box-shadow: 
        0px 1px 0 var(--plinth-side),
        0px 2px 0 var(--plinth-side),
        0px 3px 0 var(--plinth-side),
        0px 4px 0 var(--plinth-side),
        0px 5px 0 var(--plinth-side),
        0px 6px 0 var(--plinth-side),
        0px 7px 0 var(--plinth-side),
        0px 8px 0 var(--plinth-side),
        0px 9px 0 var(--plinth-side),
        0px 10px 0 var(--plinth-side),
        0px 11px 0 var(--plinth-side),
        0px 12px 0 var(--plinth-side),
        0px 20px 30px var(--plinth-shadow),
        0px 30px 50px rgba(0,0,0,0.8);
    transition: all var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
}

/* Adding texture to the wood base */
.turntable-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 6px;
    background-image: repeating-linear-gradient(90deg, transparent, transparent 40px, rgba(0,0,0,0.03) 40px, rgba(0,0,0,0.03) 45px);
    pointer-events: none;
}

/* Dust Cover Hinges */
.dust-cover-hinges {
    position: absolute;
    top: -5px;
    left: 10%;
    right: 10%;
    height: 10px;
    display: flex;
    justify-content: space-between;
    transform: translateZ(12px);
}
.hinge {
    width: 30px;
    height: 20px;
    background: #111;
    border-radius: 4px;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.5);
    transform: translateY(-50%);
}

.turntable-platter {
    width: 310px;
    height: 310px;
    background: #222;
    border-radius: 50%;
    position: absolute;
    top: 45px;
    left: 45px;
    transform-style: preserve-3d;
    transform: translateZ(15px); /* Raised off the plinth */
    box-shadow: 
        0px 1px 0 #222,
        0px 2px 0 #1a1a1a,
        0px 3px 0 #151515,
        0px 4px 0 #111,
        0px 5px 0 #0a0a0a,
        0px 6px 0 #000,
        0px 7px 0 #000,
        0px 8px 0 #000,
        0px 15px 25px rgba(0,0,0,0.9);
}

.platter-edge {
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    background: repeating-conic-gradient(#333 0 2deg, #111 2deg 4deg);
    z-index: -1;
    transform: translateZ(-1px);
}

.vinyl-record {
    width: 300px;
    height: 300px;
    background: #111;
    border-radius: 50%;
    position: absolute;
    top: 5px;
    left: 5px;
    transform-style: preserve-3d;
    transform: translateZ(5px);
    box-shadow: 
        0px 1px 0 #050505,
        0px 2px 0 #000,
        inset 0 0 10px rgba(0,0,0,0.5);
}

.grooves {
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    background: 
        repeating-radial-gradient(#111, #111 2px, #1c1c1c 3px, #111 4px),
        conic-gradient(transparent 0%, rgba(255,255,255,0.2) 15%, transparent 30%, transparent 50%, rgba(255,255,255,0.2) 65%, transparent 80%);
    background-blend-mode: color-dodge;
    pointer-events: none;
    z-index: 2;
}

.vinyl-record.spinning { animation: spin 1.8s linear infinite; }
@keyframes spin { 100% { transform: translateZ(5px) rotateZ(360deg); } }

.center-label {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px solid #111;
    background: #111;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) translateZ(1px);
    z-index: 10;
    overflow: hidden;
}
.center-label img { width: 100%; height: 100%; object-fit: cover; }

/* spindle */
.vinyl-record::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 12px; height: 12px;
    background: radial-gradient(circle, #ddd, #555);
    border-radius: 50%;
    transform: translate(-50%, -50%) translateZ(4px);
    box-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    z-index: 15;
}

.tonearm-base {
    position: absolute;
    top: 50px;
    right: 40px;
    width: 80px;
    height: 80px;
    background: #1a1a1a;
    border-radius: 50%;
    transform-style: preserve-3d;
    transform: translateZ(8px);
    box-shadow: 
        0px 1px 0 #151515,
        0px 2px 0 #111,
        0px 3px 0 #0a0a0a,
        0px 4px 0 #000,
        0px 5px 0 #000,
        0px 6px 0 #000,
        0px 12px 15px rgba(0,0,0,0.8);
}
.tonearm-pivot {
    position: absolute;
    top: 50%; left: 50%;
    width: 40px; height: 40px;
    background: radial-gradient(circle at 30% 30%, #666, #222);
    border-radius: 50%;
    transform: translate(-50%, -50%) translateZ(12px);
    box-shadow: 
        0px 1px 0 #444,
        0px 2px 0 #222,
        0px 3px 0 #111,
        0px 4px 0 #000,
        0px 8px 10px rgba(0,0,0,0.8), 
        0px -2px 2px rgba(255,255,255,0.2) inset;
}

.tonearm {
    position: absolute;
    top: 40px; /* center of pivot */
    left: 40px; /* center of pivot width */
    width: 20px; /* Stick thickness / base */
    height: 250px; /* Total length backwards and forwards */
    transform-origin: 10px 40px; /* pivot at X=10px, Y=40px (down from counterweight) */
    /* Resting config: Points DOWN the plinth */
    transform: translate(-10px, -40px) translateZ(40px) rotateZ(-12deg); 
    transform-style: preserve-3d;
    transition: transform 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
}

.counterweight {
    position: absolute;
    top: 0px;
    left: -5px;
    width: 30px;
    height: 35px;
    background: linear-gradient(90deg, #444, #888, #222);
    border-radius: 4px;
    box-shadow: 10px 15px 15px rgba(0,0,0,0.8);
}

.arm-stick {
    position: absolute;
    top: 35px;
    left: 4px;
    width: 12px;
    height: 190px;
    background: linear-gradient(90deg, #aaa, #fff, #555);
    border-radius: 6px;
    box-shadow: 8px 12px 15px rgba(0,0,0,0.6);
}

.headshell {
    position: absolute;
    top: 220px; /* seamlessly connected precisely at stick bottom */
    left: 2px; /* centered horizontally on stick width (16px wide inside 20px tonearm) */
    width: 16px;
    height: 35px;
    background: linear-gradient(135deg, #333, #0a0a0a);
    border-radius: 4px;
    transform-origin: top center;
    transform: rotateZ(20deg) translateZ(0px); /* Angled inwards perfectly flat with stick */
    box-shadow: 
        0px 1px 0 #111,
        0px 2px 0 #000,
        4px 6px 15px rgba(0,0,0,0.7);
    border-top: 6px solid #888; /* metallic connector bracket */
}

.stylus {
    position: absolute;
    bottom: -6px;
    left: 6px;
    width: 4px;
    height: 8px;
    background: #e74c3c; /* Red stylus tip */
    border-radius: 2px;
    box-shadow: 0px 1px 2px rgba(0,0,0,0.8);
}

/* Playing State: Swing the tonearm over the record */
.turntable-hero.playing .tonearm { 
    transform: translate(-10px, -40px) translateZ(40px) rotateZ(35deg); 
}

/* Arm Rest Peg */
.arm-rest {
    position: absolute;
    top: 230px;
    right: 50px;
    width: 15px;
    height: 15px;
    background: #222;
    border-radius: 50%;
    transform-style: preserve-3d;
    transform: translateZ(28px);
    box-shadow: 
        0px 1px 0 #1a1a1a,
        0px 2px 0 #1a1a1a,
        0px 3px 0 #151515,
        0px 4px 0 #111,
        0px 5px 0 #111,
        0px 6px 0 #0a0a0a,
        0px 7px 0 #0a0a0a,
        0px 8px 0 #000,
        0px 9px 0 #000,
        0px 10px 0 #000,
        0px 15px 10px rgba(0,0,0,0.8);
}
.arm-rest::after {
    content: '';
    position: absolute;
    top: -5px; left: 0px;
    width: 15px; height: 5px; /* Clip to hold arm */
    background: #444;
    border-radius: 2px;
    box-shadow: 0px 2px 2px rgba(0,0,0,0.8);
}

/* Controls Panel */
.panel-controls {
    position: absolute;
    bottom: 30px;
    right: 30px;
    display: flex;
    gap: 15px;
    transform-style: preserve-3d;
    transform: translateZ(5px);
}

.knob-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    transform-style: preserve-3d;
}

.knob {
    width: 35px;
    height: 35px;
    background: var(--knob-main);
    border-radius: 50%;
    position: relative;
    margin-bottom: 12px;
    cursor: pointer;
    transform-style: preserve-3d;
    transform: translateZ(6px); /* Pop up */
    box-shadow: 
        0px 1px 0 #1a1a1a,
        0px 2px 0 #151515,
        0px 3px 0 #111,
        0px 4px 0 #0a0a0a,
        0px 5px 0 #0a0a0a,
        0px 6px 0 #000,
        0px 7px 0 #000,
        0px 12px 15px rgba(0,0,0,0.8);
}

.knob::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 25px; height: 25px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 60%);
    box-shadow: inset 0px 1px 2px rgba(255,255,255,0.2), 0px 1px 2px rgba(0,0,0,0.6);
}

.knob .indicator {
    width: 3px;
    height: 12px;
    background: var(--accent-color);
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%) rotate(0deg);
    transform-origin: 50% 12.5px; /* Pivot firmly around the absolute 17.5px center of the 35px knob */
    border-radius: 2px;
}

.knob-group label {
    font-size: 0.5rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--accent-color);
    opacity: 0.6;
}

/* Convert UI / Input section */
.converter-interface {
    margin-top: -10px;
    width: 100%;
    max-width: 500px;
    text-align: center;
    position: relative;
    z-index: 100;
}

input[type="text"] {
    background: transparent;
    border: none;
    border-bottom: 2px solid rgba(255,255,255,0.2);
    padding: 10px;
    width: 80%;
    color: var(--accent-color);
    font-family: var(--font-ui);
    font-size: 1rem;
    text-align: center;
    margin-bottom: 2vh;
    transition: border-bottom-color 0.3s;
}

input[type="text"]:focus { outline: none; border-bottom-color: var(--accent-color); }

button {
    padding: 12px 30px;
    background: linear-gradient(145deg, #333, #111);
    color: var(--accent-color);
    border: 1px solid #000;
    border-radius: 10px;
    font-family: var(--font-ui);
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 3px 3px 10px rgba(0,0,0,0.8), inset 1px 1px 2px rgba(255,255,255,0.1);
    font-size: 0.8rem;
    transition: all 0.2s;
}
button:hover { transform: translateY(-1px); box-shadow: 4px 4px 12px rgba(0,0,0,0.9); }
button:active { transform: translateY(1px); box-shadow: 1px 1px 5px rgba(0,0,0,0.8); }

.status {
    margin-top: 2vh;
    font-size: 0.7rem;
    letter-spacing: 2px;
    color: #888;
    text-transform: uppercase;
}
.hidden { display: none !important; }

.sticky-footer {
    height: 10vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0.3;
}
.footer-links a { color: var(--accent-color); text-decoration: none; margin: 0 15px; font-size: 0.8rem; }
