:root {
    /* Light mode colors */
    --bg-color: #f5f5f5;
    --container-bg: white;
    --text-color: #333;
    --label-color: #555;
    --border-color: #ddd;
    --input-bg: white;
    --output-bg: #f9f9f9;
    --shadow: rgba(0,0,0,0.1);
    --accent-color: #4CAF50;
    --accent-hover: #45a049;
    --secondary-color: #008CBA;
    --secondary-hover: #007B9A;
    --error-color: #d32f2f;
}

.dark-mode {
    /* Dark mode colors */
    --bg-color: #1a1a1a;
    --container-bg: #2d2d2d;
    --text-color: #e0e0e0;
    --label-color: #b0b0b0;
    --border-color: #555;
    --input-bg: #3a3a3a;
    --output-bg: #2a2a2a;
    --shadow: rgba(0,0,0,0.3);
    --accent-color: #66BB6A;
    --accent-hover: #5CBF60;
    --secondary-color: #42A5F5;
    --secondary-hover: #2196F3;
    --error-color: #f44336;
}

body {
    font-family: Arial, sans-serif;
    max-width: 90vw;
    margin: 0 auto;
    padding: 2vh 2vw;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 96vh;
}

.container {
    background-color: var(--container-bg);
    padding: 3vh 3vw;
    border-radius: 1vw;
    box-shadow: 0 0.5vh 2vh var(--shadow);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    height: 90vh;
    display: flex;
    flex-direction: column;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3vh;
}

.header-buttons {
    display: flex;
    gap: 1vw;
    align-items: center;
}

h1 {
    color: var(--text-color);
    text-align: center;
    margin: 0;
    font-size: 3vw;
    flex-grow: 1;
    transition: color 0.3s ease;
}

.theme-toggle {
    background: none;
    border: 0.2vh solid var(--border-color);
    border-radius: 50%;
    width: 5vh;
    height: 5vh;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2vh;
    transition: all 0.3s ease;
    color: var(--text-color);
    background-color: var(--container-bg);
}

.help-toggle {
    background: none;
    border: 0.2vh solid var(--border-color);
    border-radius: 50%;
    width: 5vh;
    height: 5vh;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2vh;
    font-weight: bold;
    transition: all 0.3s ease;
    color: var(--text-color);
    background-color: var(--container-bg);
}

.theme-toggle:hover,
.help-toggle:hover {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    transform: scale(1.1);
}

.main-content {
    display: flex;
    gap: 3vw;
    align-items: stretch;
    flex: 1;
    min-height: 0;
}

.form-section {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.output-section {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.form-group {
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

label {
    display: block;
    margin-bottom: 1vh;
    font-weight: bold;
    color: var(--label-color);
    font-size: 1.8vh;
    transition: color 0.3s ease;
}

#codeInput {
    width: 100%;
    flex: 1;
    padding: 2vh;
    border: 0.2vh solid var(--border-color);
    border-radius: 0.5vh;
    font-family: 'Courier New', monospace;
    font-size: 1.6vh;
    resize: none;
    box-sizing: border-box;
    background-color: var(--input-bg);
    color: var(--text-color);
    transition: all 0.3s ease;
    min-height: 0;
    max-height: none;
}

#codeInput:focus {
    border-color: var(--accent-color);
    outline: none;
    box-shadow: 0 0 0 0.2vh var(--accent-color);
}

.button-group {
    display: flex;
    gap: 2vw;
    margin: 2vh 0 0 0;
    flex-shrink: 0;
}

.btn {
    padding: 1.5vh 3vw;
    font-size: 1.8vh;
    border: none;
    border-radius: 0.5vh;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    min-width: 10vw;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn:hover:not(:disabled) {
    transform: translateY(-0.2vh);
    box-shadow: 0 0.5vh 1vh var(--shadow);
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--accent-hover);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--secondary-hover);
}

#output {
    width: 100%;
    flex: 1;
    padding: 2vh;
    border: 0.2vh solid var(--border-color);
    border-radius: 0.5vh;
    font-family: 'Courier New', monospace;
    font-size: 1.6vh;
    background-color: var(--output-bg);
    color: var(--text-color);
    box-sizing: border-box;
    resize: none;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-y: auto;
    overflow-x: hidden;
    transition: all 0.3s ease;
    min-height: 0;
    max-height: none;
}

.output-label {
    margin-top: 0;
    margin-bottom: 1vh;
}

/* Responsive design for smaller screens */
@media (max-width: 968px) {
    .main-content {
        flex-direction: column;
        gap: 2vh;
    }
    
    h1 {
        font-size: 4vw;
    }
    
    .container {
        height: auto;
        min-height: 90vh;
    }
}

@media (max-width: 768px) {
    body {
        padding: 1vh 1vw;
    }
    
    .container {
        padding: 2vh 2vw;
    }
    
    .header {
        margin-bottom: 2vh;
    }
    
    h1 {
        font-size: 6vw;
    }
    
    .theme-toggle {
        width: 4vh;
        height: 4vh;
        font-size: 1.8vh;
    }
    
    .main-content {
        flex-direction: column;
        gap: 2vh;
    }
    
    .button-group {
        flex-direction: column;
        gap: 1vh;
    }
    
    .btn {
        width: 100%;
        padding: 2vh;
        font-size: 2vh;
    }
    
    #codeInput {
        min-height: 35vh;
        font-size: 1.8vh;
    }
    
    #output {
        min-height: 25vh;
        font-size: 1.8vh;
    }
    
    label {
        font-size: 2vh;
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
}

.modal-content {
    background-color: var(--container-bg);
    margin: 5% auto;
    padding: 0;
    border-radius: 1vh;
    width: 80%;
    max-width: 60vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 1vh 3vh rgba(0, 0, 0, 0.3);
    animation: modalFadeIn 0.3s ease-out;
}

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

.modal-header {
    background-color: var(--accent-color);
    color: white;
    padding: 2vh 3vh;
    border-radius: 1vh 1vh 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 2.5vh;
}

.close {
    color: white;
    font-size: 4vh;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
    line-height: 1;
}

.close:hover {
    color: #ddd;
}

.modal-body {
    padding: 3vh;
    color: var(--text-color);
    line-height: 1.6;
}

.modal-body h3 {
    color: var(--accent-color);
    margin: 2vh 0 1vh 0;
    font-size: 2vh;
    border-bottom: 0.1vh solid var(--border-color);
    padding-bottom: 0.5vh;
}

.modal-body h3:first-child {
    margin-top: 0;
}

.modal-body code {
    background-color: var(--output-bg);
    border: 0.1vh solid var(--border-color);
    border-radius: 0.3vh;
    padding: 1vh;
    display: block;
    font-family: 'Courier New', monospace;
    font-size: 1.4vh;
    white-space: pre-line;
    margin: 1vh 0 2vh 0;
    color: var(--text-color);
    overflow-x: auto;
}

/* Mobile modal adjustments */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-width: 95vw;
        margin: 10% auto;
        max-height: 70vh;
    }
    
    .modal-header {
        padding: 1.5vh 2vh;
    }
    
    .modal-header h2 {
        font-size: 2vh;
    }
    
    .close {
        font-size: 3vh;
    }
    
    .modal-body {
        padding: 2vh;
    }
    
    .modal-body h3 {
        font-size: 1.8vh;
    }
    
    .modal-body code {
        font-size: 1.2vh;
        padding: 0.8vh;
    }
}
