:root {
    /* Color Palette: Warm Charcoal with Coral & Gold accents */
    --bg-primary: #0A0A0B;
    --bg-secondary: #111113;
    --bg-card: #161618;
    --bg-card-hover: #1C1C1F;
    --accent-coral: #FF6B5B;
    --accent-coral-dim: rgba(255, 107, 91, 0.15);
    --accent-gold: #E8C872;
    --accent-gold-dim: rgba(232, 200, 114, 0.12);
    --text-primary: #F5F5F3;
    --text-secondary: #8A8A8D;
    --text-tertiary: #5A5A5D;
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* Noise texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
    z-index: 1000;
}

/* Ambient glow effects */
.ambient-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.4;
    pointer-events: none;
    z-index: -1;
}

.glow-coral {
    width: 600px;
    height: 600px;
    background: var(--accent-coral);
    top: -200px;
    right: -200px;
    opacity: 0.08;
}

.glow-gold {
    width: 500px;
    height: 500px;
    background: var(--accent-gold);
    bottom: -150px;
    left: -150px;
    opacity: 0.06;
}

.app-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 40px;
    width: 100%;
    max-width: 1200px;
    padding: 80px 48px;
    margin: 0 auto;
    align-items: start;
}

/* Container */
.container {
    width: 100%;
    text-align: center;
}

/* Navigation & Back Button */
.top-nav {
    display: flex !important;
    justify-content: flex-start !important;
    margin-bottom: 32px !important;
    width: 100% !important;
    text-align: left !important;
}

.back-link,
a.back-link {
    color: var(--text-secondary) !important;
    text-decoration: none !important;
    font-size: 0.85rem !important;
    font-weight: 500 !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 10px 20px !important;
    border-radius: 100px !important;
    border: 1px solid var(--border-subtle) !important;
    background: rgba(255, 255, 255, 0.03) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    margin: 0 !important;
}

.back-link:hover,
a.back-link:hover {
    color: var(--text-primary) !important;
    background: var(--bg-card) !important;
    border-color: var(--border-hover) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2) !important;
}

.back-link .arrow {
    transition: transform 0.3s ease !important;
    font-size: 1.1rem !important;
    line-height: 1 !important;
    display: inline-block !important;
}

.back-link:hover .arrow {
    transform: translateX(-4px) !important;
}

header {
    margin-bottom: 48px;
}

header h1 {
    font-family: 'Instrument Serif', Georgia, serif;
    font-weight: 400;
    letter-spacing: -0.02em;
    font-size: 3rem;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 0;
}

/* Controls Card */
.controls-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 32px 64px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 32px;
    transition: all 0.4s ease;
}

.controls-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
}

.preset-selector {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.preset-btn {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 100px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.preset-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.preset-btn.active {
    background: var(--text-primary);
    border-color: var(--text-primary);
    color: var(--bg-primary);
}

.status-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pulse-ring {
    width: 8px;
    height: 8px;
    background: var(--accent-coral);
    border-radius: 50%;
    margin-bottom: 12px;
    transition: all 0.3s ease;
}

.pulse-ring.active {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.4);
        box-shadow: 0 0 12px var(--accent-coral);
    }
}

#status-text {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
}

.frequency-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.wave-visualizer {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 48px;
}

.bar {
    width: 6px;
    height: 8px;
    background: var(--accent-coral);
    border-radius: 100px;
    opacity: 0.2;
    transition: all 0.3s ease;
}

.pulse-ring.active~.frequency-display .bar,
.playing-active .bar {
    animation: bar-pulse 1.2s infinite ease-in-out;
}

.bar:nth-child(2) {
    animation-delay: 0.15s;
}

.bar:nth-child(3) {
    animation-delay: 0.3s;
}

.bar:nth-child(4) {
    animation-delay: 0.45s;
}

.bar:nth-child(5) {
    animation-delay: 0.6s;
}

@keyframes bar-pulse {

    0%,
    100% {
        height: 8px;
        opacity: 0.2;
    }

    50% {
        height: 40px;
        opacity: 1;
    }
}

.freq-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.freq-box .label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.freq-box .value {
    font-family: 'Instrument Serif', serif;
    font-size: 4.5rem;
    font-weight: 400;
    line-height: 1;
    color: var(--text-primary);
}

.freq-box .unit {
    font-size: 1.1rem;
    color: var(--text-tertiary);
    margin-top: -4px;
}

/* Sliders */
.sliders {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.input-group {
    display: flex;
    flex-direction: column;
    text-align: left;
    gap: 12px;
}

.input-group.master-group {
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 8px;
}

.input-group.master-group label {
    color: var(--text-primary);
    font-weight: 500;
}

.input-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.label-with-presets {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.noise-type-selector {
    display: flex;
    gap: 10px;
}

.noise-color-btn {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.noise-color-btn.white {
    background: #FFFFFF;
}

.noise-color-btn.pink {
    background: #FF66CC;
}

.noise-color-btn.brown {
    background: #8B4513;
}

.noise-color-btn.blue {
    background: #2196F3;
}

.noise-color-btn.violet {
    background: #9C27B0;
}

.noise-color-btn:hover {
    transform: scale(1.2);
    border-color: var(--border-hover);
}

.noise-color-btn.active {
    border-color: var(--text-primary);
    transform: scale(1.25);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--bg-secondary);
    border-radius: 100px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--text-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider-value {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    align-self: flex-end;
    margin-top: -30px;
}

/* Primary Button */
.primary-btn {
    width: 100%;
    padding: 18px;
    border: none;
    border-radius: 100px;
    background: var(--text-primary);
    color: var(--bg-primary);
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(245, 245, 243, 0.15);
}

.primary-btn.playing {
    background: var(--accent-coral);
    color: white;
}

.action-row {
    margin-top: 8px;
}

.secondary-btn {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border-subtle);
    border-radius: 100px;
    background: transparent;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--border-hover);
}

/* Sidebar */
.presets-sidebar {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 24px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.presets-sidebar h2 {
    font-family: 'Instrument Serif', serif;
    font-weight: 400;
    font-size: 1.5rem;
}

.main-logo {
    height: 64px;
    width: auto;
    margin-bottom: 12px;
}

.presets-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.preset-item {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.preset-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: translateX(4px);
}

.preset-name {
    display: block;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.preset-meta {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.delete-preset {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 8px;
    transition: color 0.3s ease;
}

.delete-preset:hover {
    color: var(--accent-coral);
}

.empty-msg {
    color: var(--text-tertiary);
    font-size: 0.9rem;
    font-style: italic;
    text-align: center;
}

.hint {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    font-style: italic;
    text-align: center;
}

footer {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
}

footer p {
    font-size: 0.9rem;
    color: var(--text-tertiary);
}

/* Responsiveness */
@media (max-width: 1024px) {
    .app-layout {
        grid-template-columns: 1fr;
        padding: 40px 24px;
        max-width: 600px;
    }

    header h1 {
        font-size: 2.5rem;
    }
}

@media (max-width: 480px) {
    .controls-card {
        padding: 24px;
    }

    .freq-box .value {
        font-size: 3.5rem;
    }
}