:root {
    /* Computed by JavaScript */
    --scale: 1;
    
    /* Base units - adjust these to resize entire UI */
    --base-unit: 16px;
    --base-font: 16px;
    
    /* All spacing derives from base units */
    --unit: calc(var(--base-unit) * var(--scale));
    --font-size: calc(var(--base-font) * var(--scale));
    
    /* Visual properties */
    --border-radius: calc(8px * var(--scale));
    --text-color: #333;
    --primary-color: #1a6887;
    --light-gray: #f0f2f5;
    --border-color: #d9d9d9;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--light-gray);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: var(--font-size);
    line-height: 1.5;
}

.container {
    display: flex;
    width: 95vw;
    height: 95vh;
    background-color: #ffffff;
    box-shadow: 0 calc(4px * var(--scale)) calc(12px * var(--scale)) rgba(0, 0, 0, 0.1);
    overflow: hidden;
    border: calc(1px * var(--scale)) solid var(--border-color);
    border-radius: var(--border-radius);
}

.panel {
    display: flex;
    flex-direction: column;
    padding: calc(var(--unit) * 1.5);
    overflow-y: auto;
}

.left-panel {
    flex: 1 1 50%;
    border-right: calc(1px * var(--scale)) solid var(--border-color);
    background-color: #fafafa;
    padding-right: calc(var(--unit) * 2);
}

.right-panel {
    flex: 1 1 50%;
    background-color: #2b2b2b;
    color: #f0f0f0;
    padding: calc(var(--unit) * 1.5);
    padding-left: calc(var(--unit) * 2);
}

.control-group {
    margin-bottom: calc(var(--unit) * 0.4);
}

.control-group h2 {
    font-size: calc(var(--font-size) * 1.2);
    font-weight: 600;
    margin-bottom: var(--unit);
    color: #1a1a1a;
}

hr {
    border: none;
    border-top: calc(1px * var(--scale)) solid #e0e0e0;
    margin: calc(var(--unit) * 1.5) 0;
}

label {
    font-size: var(--font-size);
    font-weight: 500;
    color: var(--text-color);
}

.file-input-group {
    display: block;
}

.file-input-group .browse-btn {
    margin-bottom: calc(var(--unit) * 0.75);
}
.input-button-row {
    display: flex;
    align-items: center;
    gap: calc(var(--unit) * 0.75);
    margin-bottom: calc(var(--unit) * 0.75);
}

.or-text {
    font-size: var(--font-size);
    font-weight: 500;
    color: var(--text-color);
}

input[type="text"], select {
    width: 100%;
    padding: calc(var(--unit) * 0.5) calc(var(--unit) * 0.75);
    border: calc(1px * var(--scale)) solid #ccc;
    border-radius: var(--border-radius);
    font-size: var(--font-size);
    background-color: #fff;
    height: calc(var(--unit) * 2.5);
}

.browse-btn, .help-btn {
    flex-shrink: 0;
    padding: 0 calc(var(--unit) * 1.25);
    border: calc(1px * var(--scale)) solid #ccc;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: var(--font-size);
    font-weight: 500;
    transition: background-color 0.2s ease;
    background-color: #f5f5f5;
    color: var(--text-color);
    height: calc(var(--unit) * 2.5);
}

.browse-btn:hover, .help-btn:hover {
    background-color: #e9e9e9;
}

.radio-group {
    margin-top: calc(var(--unit) * 1.2);
    display: flex;
    flex-direction: column;
    gap: calc(var(--unit) * 0.5);
}

.radio-group label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

input[type="radio"], input[type="checkbox"] {
    margin-right: calc(var(--unit) * 0.6);
    width: calc(var(--font-size) * 1.2);
    height: calc(var(--font-size) * 1.2);
    accent-color: var(--primary-color);
}

.flex-label {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: calc(var(--unit) * 1.5);
    align-items: center;
}

.horizontal-group {
    display: flex;
    flex-wrap: wrap;
    gap: calc(var(--unit) * 1.5);
    align-items: flex-end;
}

.sub-group {
    flex: 1;
    min-width: calc(var(--unit) * 12);
}

.sub-group label {
    display: block;
    margin-bottom: calc(var(--unit) * 0.6);
    font-size: calc(var(--font-size) * 1.2);
    font-weight: 600;
    color: #1a1a1a;
}

.options-group {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: calc(var(--unit) * 1.5);
    margin-bottom: calc(var(--unit) * 1.2);
}

/* Left column: button on top, checkboxes underneath aligned with button's left edge */
.options-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: calc(var(--unit) * 1.0); /* small space between button and checkboxes */
    flex: 1;
}
/* Match the button's left margin so the checkbox inputs line up directly beneath it */
.options-left .checkbox-group {
    margin-left: calc(var(--unit) * 0.9);
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: calc(var(--unit) * 0.6);
}

.help-btn {
    flex-shrink: 0;
    width: 100%; 
}

.help-button-stack {
    display: flex;
    flex-direction: column;
    gap: calc(var(--unit) * 0.6);
    flex-shrink: 0;
    width: 35%;
    align-self: flex-start; /* ensure right-side buttons align to the top of the row */
}

.run-btn {
    margin-top: auto;
    margin-bottom: calc(var(--unit) * 1.2);
    width: 100%;
    height: calc(var(--unit) * 4.0);
    padding: 0 calc(var(--unit) * 1.2);
    font-size: calc(var(--font-size) * 1.5);
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.run-btn:hover {
    background-color: #0979a1;
}

.run-btn:disabled {
    background-color: #1388b3;
    cursor: not-allowed;
}

.console-output {
    flex-grow: 1;
    background-color: #2b2b2b;
    color: #dcdcdc;
    border-radius: calc(6px * var(--scale));
    overflow-y: auto;
    font-family: 'Menlo', 'Consolas', 'Monaco', monospace;
    font-size: calc(var(--font-size) * 1.0);
    height: 100%;
}

.console-output pre {
    padding: var(--unit);
    white-space: pre-wrap;
    word-wrap: break-word;
}

#select-channels-btn {
    margin-left: calc(var(--unit) * 0.6);
    height: auto;
    padding: calc(var(--unit) * 0.5) var(--unit);
    font-size: calc(var(--font-size) * 0.9);
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fff;
    padding: calc(var(--unit) * 2);
    border-radius: var(--border-radius);
    box-shadow: 0 calc(8px * var(--scale)) calc(24px * var(--scale)) rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: calc(var(--unit) * 35);
    max-height: 80vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    color: var(--text-color);
}

.modal-content h2 {
    font-size: calc(var(--font-size) * 1.2);
    margin-bottom: calc(var(--unit) * 1.2);
    color: #1a1a1a;
}

.modal-content form {
    display: flex;
    flex-direction: column;
    gap: calc(var(--unit) * 0.6);
    margin-bottom: calc(var(--unit) * 1.5);
}

.modal-content label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.modal-content .run-btn {
    margin-top: auto;
    width: 100%;
}