/* ============================================================
   Engine Sound Synthesizer — Minimal Dashboard Theme
   ============================================================ */

:root {
    --bg-primary: #0d0221;
    --bg-secondary: #150535;
    --bg-card: transparent;

    --border-color: rgba(120, 40, 200, 0.2);

    --accent: #ff2d95;
    --accent-light: #ff71ce;
    --accent-glow: rgba(255, 45, 149, 0.3);

    --text-primary: #eae0ff;
    --text-secondary: rgba(220, 200, 255, 0.6);
    --text-muted: rgba(200, 180, 255, 0.3);

    --green: #00ff9f;
    --yellow: #ffe66d;
    --red: #ff4060;
    --cyan: #00d4ff;

    --radius: 8px;
    --radius-sm: 6px;
    --radius-xs: 4px;

    --transition: all 0.2s ease;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================================
   Splash Screen
   ============================================================ */
.splash {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 50% 40%, rgba(255,45,149,0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 50% 80%, rgba(100,20,200,0.06) 0%, transparent 50%),
        linear-gradient(rgba(60,20,200,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(60,20,200,0.04) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
}

.splash-content {
    text-align: center;
    animation: splashFadeIn 0.8s ease-out;
}

.splash-title {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, #ff2d95, #00d4ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.03em;
    margin-bottom: 0.4rem;
}

.splash-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 2.5rem;
}

.splash-line {
    width: 60px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-light), transparent);
    margin: 0 auto 2.5rem;
}

.btn-splash {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.9rem 2.5rem;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: transparent;
    color: var(--accent-light);
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-splash:hover {
    background: rgba(255, 45, 149, 0.08);
    box-shadow: 0 0 30px rgba(255, 45, 149, 0.2), 0 0 60px rgba(255, 45, 149, 0.1);
    transform: translateY(-2px);
}

.splash.fade-out {
    animation: splashFadeOut 0.5s ease-in forwards;
}

@keyframes splashFadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes splashFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes dashboardFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.app.fade-in {
    animation: dashboardFadeIn 0.4s ease-out;
}

/* ---- App Container ---- */
.app {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.25rem 2rem;
}

/* ============================================================
   Header
   ============================================================ */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.2rem 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0;
    flex-wrap: wrap;
    gap: 1rem;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #ff2d95, #00d4ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.subtitle {
    display: block;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
    font-weight: 400;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.vol-icon {
    display: flex;
    align-items: center;
    color: var(--accent-light);
    cursor: pointer;
}
.vol-slider {
    width: 80px;
    accent-color: var(--accent);
}

.btn-start {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.3rem;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--accent), #e05a2b);
    color: #fff;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-start:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-start.running {
    background: linear-gradient(135deg, var(--red), #c53030);
    box-shadow: 0 2px 12px rgba(239, 68, 68, 0.25);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
}

.btn-pause {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.55rem 1.3rem;
    border: 1px solid var(--accent-light);
    border-radius: var(--radius);
    background: transparent;
    color: var(--accent-light);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 110px;
}

.btn-pause:hover {
    background: rgba(255, 113, 206, 0.08);
}

.btn-stop {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.3rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-stop:hover {
    border-color: var(--red);
    color: var(--red);
}

/* ============================================================
   Preset Bar
   ============================================================ */
.presets-bar {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    flex-wrap: wrap;
}

.presets-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.preset-buttons { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.preset-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.45rem 0.9rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
}

.preset-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.preset-btn.active {
    border-color: var(--accent);
    color: var(--text-primary);
    background: rgba(255, 45, 149, 0.06);
}

.preset-name {
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.2;
}

.preset-desc {
    font-size: 0.62rem;
    color: var(--text-muted);
    line-height: 1.2;
    margin-top: 0.1rem;
}

.preset-btn.active .preset-desc { color: var(--accent); }

/* ---- Demo Drive Group (inside tach card) ---- */
.demo-drive-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.drive-select {
    padding: 0.4rem 0.6rem;
    border: none;
    border-radius: var(--radius-sm);
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    padding-right: 1.4rem;
}

.drive-select option {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.drive-select:hover:not(:disabled) {
    color: var(--text-primary);
}

.drive-select:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.btn-demo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.45rem 1rem;
    border: 1px solid var(--accent-light);
    border-radius: var(--radius);
    background: transparent;
    color: var(--accent-light);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    white-space: nowrap;
    min-width: 120px;
}

.btn-demo:hover:not(:disabled) {
    background: rgba(255, 113, 206, 0.08);
}

.btn-demo:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.btn-demo.active {
    background: rgba(255, 113, 206, 0.1);
    box-shadow: 0 0 12px rgba(255, 113, 206, 0.2);
    animation: pulse-glow 1.5s ease-in-out infinite;
}

/* ============================================================
   Top Section: Engine Block (left) + Graphs (right)
   ============================================================ */
.top-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    margin: 0;
    align-items: stretch;
}

/* Engine block — left half */
.engine-viz-card {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
    /* Subtle grid background */
    background-image:
        linear-gradient(rgba(60,20,200,0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(60,20,200,0.07) 1px, transparent 1px);
    background-size: 20px 20px;
}

#engineCanvas {
    width: 100%;
    height: 100%;
    display: block;
    flex: 1;
    min-height: 300px;
}

/* Right column */
.right-graphs {
    display: flex;
    flex-direction: column;
}

.viz-card {
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.viz-card canvas {
    width: 100%;
    height: 120px;
    display: block;
}

.tach-card {
    padding: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    gap: 1rem;
    flex: 1;
    border: 1px solid var(--border-color);
}

.tach-right {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.8rem;
    flex: 0 0 auto;
}

#tachCanvas {
    width: 100%;
    height: 100%;
    max-width: 280px;
    max-height: 280px;
    display: block;
    flex-shrink: 0;
}

.tach-controls {
    display: flex;
    flex-direction: row;
    gap: 2rem;
    align-items: stretch;
    justify-content: center;
    height: 240px;
}

.slider-row.vertical {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0;
}

.slider-row.vertical input[type="range"] {
    writing-mode: vertical-lr;
    direction: rtl;
    width: 6px;
    height: auto;
    flex: 1;
    min-height: 0;
}

/* ============================================================
   Viz Header / Badge
   ============================================================ */
.viz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.9rem;
    border-bottom: 1px solid var(--border-color);
}

.viz-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.viz-badge {
    font-size: 0.62rem;
    font-weight: 500;
    color: var(--accent);
    padding: 0.1rem 0.4rem;
    border-radius: 20px;
    letter-spacing: 0.03em;
    transition: var(--transition);
}

.viz-badge.running {
    color: var(--green);
    animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.3); }
    50% { box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.0); }
}

/* ============================================================
   Parameter Grid — flat dashboard with divider lines
   ============================================================ */
.param-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0;
}

.control-card {
    padding: 1rem 1.1rem;
    border: 1px solid var(--border-color);
    transition: background 0.2s ease;
}

.control-card:hover {
    background: rgba(255, 255, 255, 0.015);
}


.card-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.card-icon {
    display: inline-flex;
    align-items: center;
    color: var(--accent-light);
}

/* ---- Slider Rows ---- */
.slider-row {
    display: grid;
    grid-template-columns: 90px 1fr 65px;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.slider-row:last-child { margin-bottom: 0; }

.slider-row label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.slider-value {
    font-size: 0.78rem;
    color: var(--accent-light);
    text-align: right;
    font-weight: 500;
}

.slider-value.mono { font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; }

/* ---- Range Input ---- */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.08);
    outline: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

input[type="range"]:hover { background: rgba(255, 255, 255, 0.14); }

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    box-shadow: 0 1px 6px var(--accent-glow);
    transition: all 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 10px var(--accent-glow);
}

input[type="range"]:active::-webkit-slider-thumb {
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    box-shadow: 0 1px 6px var(--accent-glow);
}

/* ---- Engine Builder (overlay inside engine-viz-card) ---- */
.builder-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(13, 2, 33, 0.92);
    backdrop-filter: blur(12px);
}

.builder-panel .card-title {
    margin-bottom: 0.6rem;
    color: var(--accent-light);
}

.custom-select {
    background: transparent;
    color: var(--text-primary);
    border: none;
    border-radius: var(--radius-xs);
    padding: 0.3rem 0.5rem;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    min-width: 130px;
    cursor: pointer;
    transition: var(--transition);
}

.custom-select:hover, .custom-select:focus {
    color: var(--accent-light);
}

.custom-select option {
    background: #0d0221;
    color: var(--text-primary);
    padding: 0.5rem;
}

.btn-apply {
    padding: 0.45rem 1rem;
    font-size: 0.82rem;
    margin-top: auto;
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
    text-align: center;
    padding: 1.5rem 0 0.5rem;
    margin-top: 0;
}

.footer p {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
    .top-section {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .top-section {
        grid-template-columns: 1fr;
    }
    .engine-viz-card {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    #engineCanvas { min-height: 250px; }
    #tachCanvas { max-width: 240px; max-height: 240px; }
    .tach-card { flex-direction: column; }
    .tach-controls { width: 100%; height: 160px; justify-content: center; }
    .param-grid { grid-template-columns: 1fr; }
    .control-card { border: 1px solid var(--border-color); }
    .header { flex-direction: column; align-items: flex-start; }
    .header-right { width: 100%; justify-content: space-between; }
    .slider-row { grid-template-columns: 80px 1fr 55px; }
}

@media (max-width: 480px) {
    html { font-size: 13px; }
    .preset-buttons { flex-wrap: nowrap; overflow-x: auto; }
    .preset-btn { min-width: 70px; padding: 0.35rem 0.6rem; }
}

/* ============================================================
   Animations
   ============================================================ */
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
    50% { box-shadow: 0 0 16px 2px var(--accent-glow); }
}

.btn-start.running { animation: pulse-glow 2s ease-in-out infinite; }
