:root {
    --bg-dark: #0A0A14;
    --bg-panel: rgba(24, 24, 27, 0.6);
    --bg-panel-solid: #18181B;
    --accent-primary: #7B61FF;
    --accent-primary-glow: #7B61FF80;
    --text-main: #F0EFF4;
    --text-muted: rgba(240, 239, 244, 0.5);

    --font-heading: 'Sora', sans-serif;
    --font-mono: 'Fira Code', monospace;
    --font-drama: 'Instrument Serif', serif;

    --tw-void: 10 10 20;
    --tw-plasma: 123 97 255;
    --tw-ghost: 240 239 244;
    --tw-graphite: 24 24 27;
}

:root[data-theme="light"] {
    --tw-void: 220 220 225;
    --tw-plasma: 60 40 200;
    --tw-ghost: 10 10 20;
    --tw-graphite: 255 255 255;
    --bg-dark: #F0EFF4;
    --bg-panel: rgba(240, 240, 245, 0.6);
    --bg-panel-solid: #ffffff;
    --accent-primary: #3C28C8;
    --text-main: #0A0A14;
    --text-muted: rgba(10, 10, 20, 0.5);
}

:root[data-theme="hc-dark"] {
    --tw-void: 0 0 0;
    --tw-plasma: 0 255 0;
    --tw-ghost: 255 255 255;
    --tw-graphite: 0 0 0;
    --bg-dark: #000000;
    --bg-panel: rgba(0, 0, 0, 0.8);
    --bg-panel-solid: #000000;
    --accent-primary: #00FF00;
    --text-main: #FFFFFF;
    --text-muted: #00FF00;
}
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-heading);
    overflow-x: hidden;
    min-height: 100vh;
    background-image:
        radial-gradient(circle at 50% 10%, rgba(123, 97, 255, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 10% 80%, rgba(123, 97, 255, 0.08) 0%, transparent 30%);
}

#vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    box-shadow: inset 0 0 150px rgba(10, 10, 20, 0.9);
    z-index: 100;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    position: relative;
    z-index: 10;
    letter-spacing: -0.02em;
    /* Sora tight tracking */
}

/* Typography elements */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(123, 97, 255, 0.2);
    padding-bottom: 1rem;
}

.logo-container h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    text-transform: uppercase;
    margin: 0;
    color: var(--text-main);
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.3), 0 0 40px rgba(123, 97, 255, 0.4);
}

.logo-container .subtitle {
    font-family: var(--font-drama);
    font-size: 1.8rem;
    font-weight: 400;
    font-style: italic;
    color: var(--accent-primary);
    margin-top: -0.3rem;
    text-shadow: 0 0 15px rgba(123, 97, 255, 0.5);
}

.glass-panel {
    background: rgba(10, 10, 20, 0.85);
    /* Deep Void */
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(123, 97, 255, 0.15);
    /* Plasma accent border */
    border-radius: 3rem;
    /* Max radiius for preset D */
    padding: 3rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), inset 0 0 40px rgba(123, 97, 255, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), inset 0 0 60px rgba(123, 97, 255, 0.1), 0 0 30px rgba(123, 97, 255, 0.15);
}

.modules-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.aira-panel {
    padding: 1.5rem 2rem;
}

.aira-status {
    max-width: 42rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.4;
    text-align: right;
}

.aira-grid {
    display: grid;
    grid-template-columns: minmax(280px, 1.4fr) minmax(240px, 0.8fr);
    gap: 1.25rem;
    align-items: stretch;
}

.access-toggle-grid,
.api-status-grid {
    display: grid;
    gap: 0.75rem;
}

.access-toggle-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.access-pill {
    min-height: 44px;
    border: 1px solid rgba(123, 97, 255, 0.35);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
    border-radius: 0.75rem;
    padding: 0.65rem 0.8rem;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0;
}

.access-pill.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: rgb(var(--tw-void));
    box-shadow: 0 0 18px rgba(123, 97, 255, 0.28);
}

.api-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.api-status-grid div {
    min-height: 54px;
    display: grid;
    align-content: center;
    gap: 0.25rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.65rem 0.8rem;
}

.api-status-grid span,
.api-status-grid strong {
    font-family: var(--font-mono);
    letter-spacing: 0;
    text-transform: uppercase;
}

.api-status-grid span {
    color: var(--text-muted);
    font-size: 0.62rem;
}

.api-status-grid strong {
    color: var(--accent-primary);
    font-size: 0.78rem;
}

.module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.5rem;
}

.module-header h2 {
    font-family: var(--font-drama);
    font-size: 1.8rem;
    font-style: italic;
    font-weight: 400;
    color: var(--text-main);
}

.sub-modules {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sub-module h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 1rem;
}

/* React specific standard containers */
.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.control-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Select */
select.premium-select {
    appearance: none;
    background: rgba(10, 10, 20, 0.8);
    border: 1px solid rgba(123, 97, 255, 0.3);
    color: var(--accent-primary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
}

select.premium-select:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px var(--accent-primary-glow);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-panel-solid);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    transition: .4s;
}

.toggle-switch .slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 6px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-muted);
    border-radius: 2px;
    transition: .4s;
}

.toggle-switch input:checked+.slider {
    background-color: rgba(123, 97, 255, 0.2);
    border-color: var(--accent-primary);
}

.toggle-switch input:checked+.slider:before {
    transform: translateX(28px);
    background-color: var(--accent-primary);
    box-shadow: 0 0 10px var(--accent-primary-glow);
}

/* Knob component internals */
.knob-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 60px;
    height: 90px;
}

.knob-wrapper {
    position: relative;
    width: 50px;
    height: 50px;
    cursor: ns-resize;
    user-select: none;
}

.knob-svg {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.knob-track {
    stroke: rgba(255, 255, 255, 0.05);
}

.knob-fill {
    stroke: var(--accent-primary);
    stroke-dasharray: 0, 300;
    transition: stroke 0.1s;
}

.knob-wrapper:hover .knob-fill,
.knob-container.dragging .knob-fill {
    stroke-width: 6;
    filter: drop-shadow(0 0 4px var(--accent-primary));
}

.knob-dial {
    position: absolute;
    top: 5px;
    left: 5px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-dark);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 2px 5px rgba(255, 255, 255, 0.05), 0 4px 10px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.knob-indicator {
    position: absolute;
    top: 2px;
    left: 50%;
    width: 2px;
    height: 10px;
    background: var(--text-main);
    transform: translateX(-50%);
    border-radius: 1px;
}

.knob-value {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--accent-primary);
    text-align: center;
}

/* Keyboard styling */
.keyboard-section {
    margin-top: 1rem;
}

.keyboard-container {
    display: flex;
    height: 120px;
    position: relative;
    justify-content: center;
}

.key {
    position: relative;
    cursor: pointer;
    border-radius: 0 0 4px 4px;
    transition: all 0.1s;
    user-select: none;
}

.key.white {
    width: 40px;
    height: 100%;
    background: #ddd;
    border: 1px solid #bbb;
    z-index: 1;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    margin: 0 1px;
}

.key.white:hover {
    background: #eee;
}

.key.white.active {
    background: #fff;
    box-shadow: 0 0 15px var(--accent-primary-glow) inset;
}

.key.black {
    width: 25px;
    height: 65%;
    background: #222;
    border: 1px solid #111;
    z-index: 2;
    margin-left: -13px;
    margin-right: -13px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
}

.key.black:hover {
    background: #333;
}

.key.black.active {
    background: #555;
    box-shadow: 0 0 10px var(--accent-primary-glow) inset;
}

/* Visualizer */
.visualizer-container {
    height: 100px;
    width: 100%;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 2rem;
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(123, 97, 255, 0.2);
}

#waveform-canvas {
    width: 100%;
    height: 100%;
}

#grain-playback-head {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 8px #fff;
    pointer-events: none;
    display: none;
}

/* Button */
.btn-primary {
    position: relative;
    background: transparent;
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 0.8rem 1.5rem;
    border-radius: 2rem;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), color 0.4s, box-shadow 0.4s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    z-index: 1;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--accent-primary);
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: -1;
}

.btn-primary:hover,
.btn-primary.active {
    color: var(--bg-dark);
    transform: scale(1.03) translateY(-1px);
    box-shadow: 0 10px 20px var(--accent-primary-glow);
}

.btn-primary:hover::before,
.btn-primary.active::before {
    transform: translateY(0);
}

.start-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 20, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

/* Bioluminescent Background */
.bg-blobs {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    z-index: 1;
    pointer-events: none;
}

.bg-blobs::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('https://images.unsplash.com/photo-1543857778-c4a1a3e0b2eb?q=80&w=2624&auto=format&fit=crop') center/cover no-repeat fixed;
    opacity: 0.08;
    mix-blend-mode: screen;
    filter: saturate(0) contrast(1.5);
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    animation: drift 20s infinite alternate ease-in-out;
    opacity: 0.6;
}

.blob-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(123, 97, 255, 0.15) 0%, transparent 70%);
    top: -100px;
    left: -100px;
    animation-duration: 25s;
}

.blob-2 {
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(10, 150, 255, 0.1) 0%, transparent 70%);
    bottom: -200px;
    right: -100px;
    animation-duration: 30s;
    animation-delay: -5s;
}

.blob-3 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(200, 50, 255, 0.1) 0%, transparent 70%);
    top: 30%;
    left: 40%;
    animation-duration: 22s;
    animation-delay: -10s;
}

@keyframes drift {
    0% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(30px, -50px) scale(1.1);
    }

    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }

    100% {
        transform: translate(40px, 40px) scale(1.05);
    }
}
/* ==============================================================
   ACCESSIBILITY & HIGH CONTRAST INCLUSIONS
   ============================================================== */

/* Ensure robust visible focus indicators for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--accent-primary, #7B61FF) !important;
    outline-offset: 4px;
    box-shadow: 0 0 0 4px rgba(123, 97, 255, 0.4);
    border-radius: 4px;
}

/* Base minimum target size for touch and motor accessibility */
.knob-container, .toggle-switch, select, button, .lucide {
    min-width: 44px;
    min-height: 44px;
}

/* Ensure form elements and interactive sliders have interaction-tolerance */
.knob-wrapper {
    cursor: grab;
    touch-action: none; /* prevent scroll while dragging sliders */
}
.knob-container.dragging .knob-wrapper {
    cursor: grabbing;
}

/* Sub-component focus management */
.focus-within\:ring-2:focus-within {
    outline: 3px solid var(--accent-primary) !important;
    outline-offset: 2px;
}

/* -----------------------------------------------------------
   REDUCED MOTION SUPPORT
   ----------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    ::before,
    ::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .bg-plasma {
        animation: none !important;
        opacity: 0.8 !important; /* Keep static visibility if pulses are disabled */
    }
    
    .knob-fill, .knob-dial {
        transition: none !important;
    }
}

html[data-motion='reduce'] *,
html[data-motion='reduce'] ::before,
html[data-motion='reduce'] ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}

html[data-focus='boost'] *:focus-visible {
    outline-width: 4px !important;
    outline-color: var(--accent-primary, #7B61FF) !important;
    outline-offset: 5px !important;
}

html[data-readable='on'] body,
html[data-readable='on'] button,
html[data-readable='on'] input,
html[data-readable='on'] select,
html[data-readable='on'] output,
html[data-readable='on'] .control-label,
html[data-readable='on'] .knob-value,
html[data-readable='on'] .font-mono {
    font-family: Arial, Helvetica, sans-serif !important;
    text-transform: none !important;
}

html[data-visuals='calm'] .bg-blobs,
html[data-visuals='calm'] #vignette,
html[data-visuals='calm'] #noise-svg,
html[data-visuals='calm'] .fixed.pointer-events-none {
    display: none !important;
}

/* ==============================================================
   CUSTOM HORIZONTAL SLIDER
   ============================================================== */
input[type=range].custom-range-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--accent-color, #7B61FF);
  border-radius: 3px;
  outline: none;
  margin: 10px 0;
}

input[type=range].custom-range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #FFF;
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent-color, #7B61FF);
  transition: transform 0.1s;
}

input[type=range].custom-range-slider:active::-webkit-slider-thumb {
  transform: scale(1.3);
}

input[type=range].custom-range-slider:focus-visible {
  outline: 2px solid var(--accent-color, #7B61FF);
  outline-offset: 4px;
}
