:root {
    --primary-color: #FF00FF;
    /* Hot Pink */
    --secondary-color: #00FFFF;
    /* Cyan */
    --accent-color: #FFFF00;
    /* Yellow */
    --bg-color: #1a051a;
    /* Darker Purple for contrast */
    --text-color: #f0f0f0;
    --card-bg: #2a1a2a;
}

.hidden {
    display: none !important;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Georgia', 'Times New Roman', serif;
    /* Serious academic font */
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.container {
    text-align: center;
    position: relative;
    /* Added for Help Button anchoring */
    background: var(--card-bg);
    padding: 2rem 2.5rem;
    /* Increased vertical padding */
    border-radius: 10px;
    border: 2px solid var(--secondary-color);
    box-shadow: 0 0 40px rgba(0, 255, 255, 0.1);
    max-width: 650px;
    /* Brining sides in */
    width: 90%;
    margin: 1rem 0;
    /* Vertical margin only, horizontal handled by flex body */
    flex-shrink: 0;
    /* Prevent container from shrinking on narrow heights */
}

h1 {
    font-family: 'Courier New', monospace;
    font-size: 1.6rem;
    margin-bottom: 1.2rem;
    color: var(--secondary-color);
    text-transform: uppercase;
    letter-spacing: 4px;
    border-bottom: 1px solid var(--primary-color);
    padding-bottom: 0.8rem;
}

.output-box {
    background-color: #fdf6e3;
    /* Manuscript paper color */
    color: #000000;
    padding: 1rem 1.5rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    min-height: 120px;
    /* Compact mode */
    display: block;
    text-align: center;
    font-size: 1.1rem;
    line-height: 1.5;
    position: relative;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.1);
    z-index: 5;
    word-wrap: break-word;
    /* Handle super long words */
    overflow-wrap: break-word;
    hyphens: auto;

    /* SCROLL LOCK (Added Jan 12 2026) */
    max-height: 250px;
    /* Cap height to keep controls visible */
    overflow-y: auto;
    /* Enable internal scroll */
    overflow-y: auto;

    /* Cross-Browser Scrollbar Styling */
    @supports (scrollbar-width: thin) {
        scrollbar-width: thin;
        scrollbar-color: var(--primary-color) #f0e6d2;
    }

    /* WebKit (Chrome/Safari/Edge) handled by ::-webkit-scrollbar below */
    transition: max-height 0.3s ease;
    /* Smooth toggle */
}

.output-box.compact {
    max-height: 140px;
    /* Reduced specific height */
    min-height: 100px;
    /* Ensures 4 lines visible */
}

/* Custom Neon Scrollbar for Output Box */
.output-box::-webkit-scrollbar {
    width: 10px;
}

.output-box::-webkit-scrollbar-track {
    background: #f0e6d2;
    border-radius: 4px;
}

.output-box::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 4px;
    border: 2px solid #f0e6d2;
}

.output-box::-webkit-scrollbar-thumb:hover {
    background-color: #d100d1;
}

/* The actual text content */
.output-box div,
.output-box span {
    width: 100%;
}

.highlight {
    color: #d33682;
    /* Solarized magenta */
    font-weight: bold;
}

.italic-prefix {
    font-style: italic;
    color: #1a5e63;
    /* Darker teal for legibility on manuscript background */
    opacity: 0.9;
    margin-right: 0.3rem;
}

.interrupt {
    font-family: inherit;
    font-weight: inherit;
    font-style: inherit;
    color: inherit;
    background: none;
    padding: 0;
    display: inline;
    transform: none;
    border: none;
}

/* Sonic Laboratory Styles */
.sonic-lab {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--secondary-color);
    width: 100%;
}

.sonic-lab h3 {
    font-family: 'Courier New', monospace;
    color: var(--accent-color);
    margin-bottom: 1rem;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.lab-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

#sonic-input {
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--accent-color);
    color: var(--text-color);
    font-size: 1.5rem;
    width: 120px;
    text-align: center;
    font-family: 'Georgia', serif;
    padding: 0.2rem;
}

#sonic-input:focus {
    outline: none;
    border-bottom-color: var(--primary-color);
}

.radios {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--text-color);
}

.mode-description {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    color: #ffd700;
    /* Gold */
    margin-top: 5px;
    margin-bottom: 15px;
    text-align: center;
    min-height: 1.2em;
    opacity: 0.8;
    font-style: italic;
}

.lab-btn {
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 0.5rem 1.5rem;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.lab-btn:hover {
    background: var(--accent-color);
    color: var(--bg-color);
    box-shadow: 0 0 10px var(--accent-color);
}

/* Dissonance Control */
/* Dissonance Control (Compacted Jan 12 2026) */
.dissonance-control {
    width: 100%;
    margin-bottom: 0;
    /* Removing external margin */
    padding: 0 0.5rem;
    /* Horizontal padding only */
    border: none;
    background: transparent;
    display: flex;
    /* Flex Row */
    align-items: center;
    gap: 1rem;
}

.dissonance-control label {
    display: inline-block;
    font-family: 'Courier New', monospace;
    color: var(--secondary-color);
    margin-bottom: 0;
    font-size: 0.8rem;
    text-transform: uppercase;
    white-space: nowrap;
    min-width: 150px;
}

.slider {
    -webkit-appearance: none;
    appearance: none;
    flex-grow: 1;
    /* Stretch to fill */
    height: 6px;
    background: var(--card-bg);
    outline: none;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    margin-bottom: 0;
    /* Remove gap */
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    /* Smaller thumb */
    height: 15px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 2px;
    box-shadow: 1px 1px 0 var(--secondary-color);
}

.lab-btn.tiny {
    padding: 0.2rem 0.8rem;
    font-size: 0.7rem;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.mode-select {
    background-color: var(--card-bg);
    color: var(--secondary-color);
    border: 1px solid var(--primary-color);
    padding: 0.6rem 1.2rem;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    border-radius: 4px;
    cursor: pointer;
    outline: none;
    box-shadow: 2px 2px 0 var(--secondary-color);
    transition: all 0.2s;
    text-align: center;
    /* Remove default arrow */
    -webkit-appearance: none;
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--primary-color) 50%),
        linear-gradient(135deg, var(--primary-color) 50%, transparent 50%);
    background-position: calc(100% - 20px) calc(1em + 2px),
        calc(100% - 15px) calc(1em + 2px);
    background-size: 5px 5px,
        5px 5px;
    background-repeat: no-repeat;
    padding-right: 3rem;
    /* Make room for arrow */
}

.mode-select:hover {
    box-shadow: 4px 4px 0 var(--secondary-color);
    transform: translateY(-1px);
}

.mode-select:focus {
    border-color: var(--accent-color);
}

.bouncy-btn {
    background-color: var(--primary-color);
    border: none;
    padding: 0.8rem 2.5rem;
    font-size: 1.1rem;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #ffffff;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 4px 4px 0 var(--secondary-color);
    transition: transform 0.1s, box-shadow 0.1s;
    text-transform: uppercase;
    letter-spacing: 2px;
    position: relative;
    /* Ensure z-index works */
    z-index: 100;
    /* Force button to be clickable */
}

.bouncy-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--secondary-color);
}

/* Animations */
.fade-in {
    animation: fadeIn 0.8s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        transform: translateY(0);
    }
}

/* Tooltip Styles (Added by Audit) */
.tooltip {
    position: absolute;
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--secondary-color);
    padding: 0.5rem 0.8rem;
    border-radius: 4px;
    font-family: 'Georgia', serif;
    font-size: 0.9rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 1000;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    max-width: 250px;
}

.tooltip strong {
    color: var(--primary-color);
    display: block;
    margin-bottom: 0.2rem;
}

.tooltip em {
    color: #aaaaaa;
    font-size: 0.8rem;
}

/* Custom Prompt Box */
#custom-prompt-container {
    width: 100%;
    margin-bottom: 1rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--secondary-color);
}

#custom-prompt-container.hidden {
    display: none;
}

#custom-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    padding: 0.5rem;
    white-space: nowrap;
    overflow-x: auto;
    outline: none;
}

#submit-custom-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
}

#submit-custom-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 10px var(--primary-color);
}

/* Remix Dashboard (Added Jan 12 2026) */
#remix-dashboard {
    width: 100%;
    margin-bottom: 0.5rem;
    /* Reduced from 1.5rem */
    padding: 0.5rem 0.8rem;
    /* Reduced from 1rem */
    /* Reduced from 0.8rem */
    box-sizing: border-box;
    /* Visual Restyle 2026 */
    background: rgba(42, 26, 42, 0.95);
    /* Deep Purple */
    border: 1px solid var(--secondary-color);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.2);
}

#remix-dashboard.hidden {
    display: none;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed var(--secondary-color);
    padding-bottom: 0.2rem;
    /* Reduced from 0.5rem */
    margin-bottom: 0.2rem;
    /* Reduced from 0.5rem */
}

.dash-title {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: var(--accent-color);
    letter-spacing: 2px;
}

#clear-remix-btn {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 0.2rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 0.8rem;
    transition: all 0.2s;
}

#clear-remix-btn:hover {
    background: var(--primary-color);
    color: white;
}

.stats-row {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
    color: var(--text-color);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.stat-item label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--secondary-color);
    opacity: 0.7;
}

.stat-item.short {
    min-width: 50px;
    text-align: center;
}

#dash-source-text {
    color: white;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

#dash-gen-count {
    color: var(--accent-color);
    font-weight: bold;
    font-size: 1.1rem;
}

.history-dropdown {
    width: 100%;
}

.history-dropdown summary {
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--secondary-color);
    text-transform: uppercase;
    padding: 0.2rem 0;
    list-style: none;
    /* Hide default triangle */
    outline: none;
    transition: color 0.2s;
}

.history-dropdown summary:hover {
    color: var(--accent-color);
}

.history-dropdown summary::-webkit-details-marker {
    display: none;
}

#dash-history-list {
    max-height: 150px;
    /* Can be taller now since it's hidden by default */
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #444;
    padding: 0.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: #eee;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.hist-entry {
    border-bottom: 1px solid #333;
    padding-bottom: 0.2rem;
}

.hist-entry:last-child {
    border-bottom: none;
}

/* Sticky Footer for Main Controls */
.sticky-footer {
    position: sticky;
    bottom: 0;
    background: #110811;
    /* Solid background to obscure content behind it */
    padding: 1rem 0;
    margin-top: 1rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-top: 2px solid var(--primary-color);
    /* Visual delineation */
    box-shadow: 0 -10px 20px rgba(0, 0, 0, 0.8);
    /* Lift it visually */
}

/* --- HELP SYSTEM STYLES (Jan 14 2026) --- */

.help-toggle {
    background: transparent;
    border: 2px solid var(--secondary-color);
    color: var(--secondary-color);
    width: 25px;
    height: 25px;
    border-radius: 50%;
    font-weight: bold;
    font-family: 'Helvetica', 'Arial', sans-serif;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.footer-help-row {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    width: 100%;
}

.help-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.help-wrapper:hover {
    opacity: 1;
}

.help-label {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--secondary-color);
    text-transform: uppercase;
    letter-spacing: 1px;
    pointer-events: none;
}

.help-toggle:hover {
    opacity: 1;
    background: var(--secondary-color);
    color: var(--bg-color);
    box-shadow: 0 0 10px var(--secondary-color);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    padding: 2rem;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.3);
    position: relative;
    text-align: left;
    font-family: 'Georgia', serif;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed var(--secondary-color);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.modal-header h2 {
    margin: 0;
    font-family: 'Courier New', monospace;
    color: var(--accent-color);
    font-size: 1.4rem;
    text-transform: uppercase;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 0.5rem;
}

.close-btn:hover {
    color: var(--primary-color);
}

.modal-body section {
    margin-bottom: 1.5rem;
}

.modal-body h3 {
    color: var(--secondary-color);
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.modal-body p {
    font-size: 0.95rem;
    line-height: 1.4;
    margin: 0.5rem 0;
    color: #ddd;
}

.help-list {
    margin: 0;
    padding-left: 1.2rem;
    color: #ddd;
    font-size: 0.95rem;
}

.help-list li {
    margin-bottom: 0.3rem;
}

/* === REMIX STATION STYLING === */
.remix-dashboard {
    font-family: 'Courier New', monospace;
    /* Match the rest of the page */
    background: var(--card-bg);
    border: 2px solid var(--accent-color);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.remix-dashboard .stats-row {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.remix-dashboard .stat-item {
    flex: 1;
}

.remix-dashboard .stat-item label {
    display: block;
    color: var(--secondary-color);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.25rem;
}

.remix-dashboard .source-controls-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.remix-dashboard #dash-source-text {
    font-style: italic;
    color: var(--text-color);
}

.icon-btn {
    background: none;
    border: 1px solid var(--secondary-color);
    color: var(--secondary-color);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: var(--secondary-color);
    color: var(--bg-color);
    transform: scale(1.1);
}

/* === SOURCE INSPECTOR MODAL - RETRO CRT STYLING === */
#source-modal {
    border: none;
    background: transparent;
    padding: 0;
    max-width: 570px;
    /* Matched to Output Box width */
    width: 90%;
    max-height: 80vh;
}

#source-modal::backdrop {
    background: rgba(0, 0, 0, 0.85);
    -webkit-backdrop-filter: blur(4px);
    /* Safari support */
    backdrop-filter: blur(4px);
}

/* Container to unify all modal sections */
#source-modal>* {
    box-sizing: border-box;
}

#source-modal .modal-header {
    background: #000;
    border: 3px solid #00ff00;
    border-bottom: 1px solid #00ff00;
    /* Thinner divider */
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px 8px 0 0;
    margin: 0;
}

#source-modal .modal-header h3 {
    margin: 0;
    font-family: 'Courier New', monospace;
    color: #00ff00;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 8px #00ff00;
}

#source-modal .close-x {
    background: none;
    border: none;
    color: #00ff00;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 0.5rem;
    text-shadow: 0 0 8px #00ff00;
    transition: all 0.2s ease;
}

#source-modal .close-x:hover {
    color: #ff0000;
    text-shadow: 0 0 12px #ff0000;
    transform: scale(1.2);
}

#source-viewer {
    width: 100%;
    min-height: 200px;
    height: 250px;
    /* Matched to Output Box max-height */
    background: #000;
    color: #00ff00;
    border-left: 3px solid #00ff00;
    border-right: 3px solid #00ff00;
    border-top: none;
    border-bottom: none;
    padding: 2.5rem 1.5rem 1.5rem;
    /* Increased top padding to clear X button */
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.5;
    resize: none;
    box-shadow: inset 0 0 20px rgba(0, 255, 0, 0.1);
    text-shadow: 0 0 3px #00ff00;
    overflow-y: auto;
    margin: 0;
    display: block;
}

/* CRT Scanline effect */
#source-viewer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(rgba(0, 0, 0, 0.05) 50%,
            transparent 50%);
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 1;
}

#source-modal .modal-footer {
    background: #000;
    border: 3px solid #00ff00;
    border-top: 1px solid #00ff00;
    /* Thinner divider */
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: flex-end;
    border-radius: 0 0 8px 8px;
    margin: 0;
}

#source-modal .lab-btn {
    background: #000;
    border: 2px solid #00ff00;
    color: #00ff00;
    padding: 0.5rem 1.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
    text-shadow: 0 0 5px #00ff00;
}

#source-modal .lab-btn:hover {
    background: #00ff00;
    color: #000;
    text-shadow: none;
    box-shadow: 0 0 15px #00ff00;
}