* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a1a;
    height: 100vh;                 /* lock layout to viewport height */
    display: grid;
    grid-template-columns: 300px 1fr;
    grid-template-rows: 100vh;     /* single row equal to viewport height */
    gap: 0;
    padding: 0;
    overflow: hidden;              /* prevent page scroll; columns manage their own */
}

body.touch-graph-lock {
    overflow: hidden !important;
    overscroll-behavior: none;
}

.mobile-toggle-btn {
    display: none;
}

.input-details {
    display: contents;
}

/* Left Column - Inputs */
.input-column {
    background: #2a2a2a;
    padding: 40px 30px;
    border-right: 1px solid #444444;
    display: flex;
    flex-direction: column;
    gap: 25px;
    /* Use flex to distribute sections; no column scroll by default */
    min-height: 0;
}

.input-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Controls Section */
.controls-section {
    margin-top: 20px;
    padding: 20px;
    background: #1a1a1a;
    border-radius: 8px;
    border: 1px solid #555555;
    /* Grow to take remaining space and scroll itself if needed */
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.controls-section h3 {
    color: #ffffff;
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 15px 0;
    font-weight: 600;
}

.control-item {
    color: #cccccc;
    font-size: 0.85em;
    line-height: 1.8;
    padding: 4px 0;
}

.control-item strong {
    color: #ffffff;
    font-weight: 600;
}

label {
    color: #cccccc;
    font-weight: 600;
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

textarea, input[type="number"] {
    width: 100%;
    padding: 12px;
    background: #1a1a1a;
    border: 2px solid #555555;
    border-radius: 6px;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    color: #ffffff;
    transition: all 0.3s ease;
}

textarea {
    resize: none;
    height: 200px;
    overflow-y: auto;
}

textarea:focus, input[type="number"]:focus {
    outline: none;
    border-color: #888888;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
    background: #0f0f0f;
}

textarea::placeholder, input[type="number"]::placeholder {
    color: #666666;
}

/* Button */
button {
    background: #666666;
    color: #ffffff;
    border: none;
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    background: #777777;
}

#generateBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background: #3a3a3a;
    color: #666666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Center Column - Graph */
.graph-column {
    background: #0f0f0f;
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;      /* keep canvas fixed and not influenced by left scroll */
    min-height: 0;         /* allow to shrink inside grid row */
}

.graph-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#graphCanvas {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    cursor: crosshair;
    touch-action: none;
}

.placeholder {
    color: #555555;
    font-size: 1.2em;
    text-align: center;
}

.placeholder.hide {
    display: none;
}

/* Right Column - Results */
.results-column {
    background: #2a2a2a;
    padding: 40px 30px;
    border-left: 1px solid #444444;
    display: flex;
    flex-direction: column;
    gap: 30px;
    justify-content: center;
}

.result-box {
    background: #1a1a1a;
    padding: 30px 25px;
    border-radius: 10px;
    border: 2px solid #555555;
    text-align: center;
    transition: all 0.3s ease;
}

.result-box:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    border-color: #777777;
}

.result-box h3 {
    color: #cccccc;
    font-size: 0.95em;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.result-value {
    font-size: 3.5em;
    font-weight: bold;
    color: #ffffff;
}

/* Responsive */
@media (max-width: 1200px) {
    body {
        grid-template-columns: 250px 1fr;
    }
    
    .input-column {
        padding: 30px 20px;
    }
    
    .graph-column {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
    }
}

@media (max-width: 900px) {
    body {
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(58vh, 1fr);
    }
    
    .input-column {
        padding: 16px 12px;
        gap: 12px;
        border-right: none;
        border-bottom: 1px solid #444444;
    }

    .mobile-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 10px 14px;
        font-size: 13px;
        letter-spacing: 0.6px;
        text-transform: uppercase;
        border-radius: 6px;
    }

    .mobile-toggle-btn .toggle-label {
        font-weight: 700;
    }

    .mobile-toggle-btn .toggle-arrow {
        display: inline-block;
        font-size: 16px;
        line-height: 1;
        transition: transform 0.25s ease;
        transform-origin: 50% 50%;
    }

    .input-details {
        display: flex;
        flex-direction: column;
        gap: 12px;
        max-height: 46vh;
        overflow-y: auto;
        padding-right: 2px;
    }

    .input-column.collapsed .input-details {
        display: none;
    }

    .input-column.collapsed #generateBtn,
    .input-column.collapsed #analyzeBtn,
    .input-column.collapsed .back-btn {
        display: none;
    }

    .input-column.collapsed .mobile-toggle-btn {
        background: #4f4f4f;
    }

    .input-column.collapsed .mobile-toggle-btn .toggle-arrow {
        transform: rotate(-90deg);
    }

    .controls-section {
        margin-top: 0;
        max-height: min(30vh, 260px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        flex: 0 0 auto;
    }

    textarea {
        height: 170px;
    }

    .back-btn {
        margin-top: 4px;
    }
    
    .graph-column {
        min-height: 62vh;
        padding: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
    }
}

/* Settings Button */
.settings-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    padding: 0;
    outline: none;
}

.settings-btn:hover {
    transform: scale(1.15);
    background: transparent;
}

.settings-btn:active {
    transform: scale(1);
    background: transparent;
}

.settings-btn:focus {
    outline: none;
    background: transparent;
}

.gear-icon {
    width: 40px;
    height: 40px;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    transition: all 0.3s ease;
}

/* Back Button (left menu style) */
.back-btn {
    display: block;
    width: 100%;
    background: #666666;
    color: #ffffff;
    border: none;
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    margin-top: 16px;
}

.back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    background: #777777;
}

.back-btn:active {
    transform: translateY(0);
}

.settings-btn:hover {
    transform: scale(1.15);
    background: transparent;
}

.settings-btn:active {
    transform: scale(1);
    background: transparent;
}

.settings-btn:focus {
    outline: none;
    background: transparent;
}

.gear-icon {
    width: 40px;
    height: 40px;
    fill: #cccccc;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    transition: all 0.3s ease;
}

.settings-btn:hover .gear-icon {
    fill: #cccccc;
}

/* Settings icon (alternative name for gear-icon) */
.settings-icon {
    width: 40px;
    height: 40px;
    stroke: #cccccc;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    transition: all 0.3s ease;
}

.settings-btn:hover .settings-icon {
    stroke: #ffffff;
}

/* Trash Button */
.trash-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    padding: 0;
    outline: none;
}

.trash-btn:hover {
    transform: scale(1.15);
    background: transparent;
}

.trash-btn:active {
    transform: scale(1);
    background: transparent;
}

.trash-btn:focus {
    outline: none;
    background: transparent;
}

.trash-icon {
    width: 40px;
    height: 40px;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    transition: all 0.3s ease;
}

/* Modal Overlay */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

/* Modal Content */
.modal-content {
    background: #2a2a2a;
    border: 2px solid #555555;
    border-radius: 12px;
    padding: 35px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    color: #ffffff;
    margin-bottom: 25px;
    font-size: 1.5em;
    border-bottom: 2px solid #444444;
    padding-bottom: 15px;
}

/* Setting Groups */
.setting-group {
    margin-bottom: 25px;
}

.setting-group label {
    display: flex;
    align-items: center;
    color: #cccccc;
    margin-bottom: 10px;
    font-size: 0.95em;
}

.setting-group label input[type="checkbox"] {
    margin-right: 10px;
    cursor: pointer;
    width: 18px;
    height: 18px;
    flex-shrink: 0; /* Prevent checkbox from shrinking */
}

/* Select Dropdown in Settings */
.setting-select {
    width: 100%;
    padding: 10px 12px;
    padding-right: 35px; /* More space for dropdown arrow */
    background: #1a1a1a;
    border: 2px solid #555555;
    border-radius: 6px;
    color: #cccccc;
    font-size: 0.95em;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.setting-select:hover {
    border-color: #666666;
}

.setting-select:focus {
    border-color: #888888;
}

.setting-select option {
    background: #1a1a1a;
    color: #cccccc;
    padding: 8px;
}

/* Range Slider Container */
.range-slider-container {
    position: relative;
    height: 30px;
    margin-top: 15px;
    padding: 10px 0;
}

.range-slider-container::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 4px;
    background: #3a3a3a;
    border-radius: 2px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.range-track-highlight {
    position: absolute;
    height: 4px;
    background: #666666;
    border-radius: 2px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 0;
}

.range-slider {
    position: absolute;
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    outline: none;
    pointer-events: none;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
}

.range-slider::-webkit-slider-track {
    width: 100%;
    height: 4px;
    background: transparent;
    border-radius: 2px;
}

.range-slider::-moz-range-track {
    width: 100%;
    height: 4px;
    background: transparent;
    border-radius: 2px;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #999999;
    border: 2px solid #cccccc;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    margin-top: 0;
    position: relative;
    z-index: 2;
}

.range-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #999999;
    border: 2px solid #cccccc;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    position: relative;
    z-index: 2;
}

.range-slider:hover::-webkit-slider-thumb {
    background: #aaaaaa;
}

.range-slider:hover::-moz-range-thumb {
    background: #aaaaaa;
}

/* Single Range Slider (standalone, not in dual-slider container) */
.single-slider {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #3a3a3a;
    outline: none;
    border-radius: 2px;
    cursor: pointer;
    margin: 15px 0;
    position: relative;
}

.single-slider::-webkit-slider-track {
    width: 100%;
    height: 4px;
    background: #3a3a3a;
    border-radius: 2px;
}

.single-slider::-moz-range-track {
    width: 100%;
    height: 4px;
    background: #3a3a3a;
    border-radius: 2px;
}

.single-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #999999;
    border: 2px solid #cccccc;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    margin-top: 0; /* No margin needed - track height matches */
}

.single-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #999999;
    border: 2px solid #cccccc;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.single-slider:hover::-webkit-slider-thumb {
    background: #aaaaaa;
    border-color: #dddddd;
}

.single-slider:hover::-moz-range-thumb {
    background: #aaaaaa;
    border-color: #dddddd;
}

.single-slider:focus {
    outline: none;
}

.single-slider:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px rgba(153, 153, 153, 0.3);
}

.single-slider:focus::-moz-range-thumb {
    box-shadow: 0 0 0 3px rgba(153, 153, 153, 0.3);
}

/* Buttons in Modal */
.setting-group:last-child {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 35px;
}

.primary-btn, .secondary-btn {
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    flex: 1;
    max-width: 150px;
}

.primary-btn {
    background: #666666;
    color: #ffffff;
}

.primary-btn:hover {
    background: #777777;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.secondary-btn {
    background: #4a4a4a;
    color: #ffffff;
}

.secondary-btn:hover {
    background: #555555;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}
