body {
    font-family: 'Inter', sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    height: 100dvh;
    margin: 0;
    background-color: #1f2937;
    color: #d1d5db;
    overflow: hidden; 
}
.main-app-container {
    position: relative;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden; 
}

/* Common styles for Sample Tray Wrappers */
.samples-tray-wrapper {
    position: fixed;
    right: 0;
    width: calc(45vw + 40px); 
    transform: translateX(45vw); 
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: row; 
    pointer-events: none; 
}
.samples-tray-wrapper.visible {
    transform: translateX(0); 
    pointer-events: auto; 
}

#puzzleSamplesTrayWrapper {
    z-index: 101; 
    top: 20px;
    height: calc(100dvh - 20px);
}
#characterSamplesTrayWrapper {
    z-index: 100;
    top: 150px; 
    height: calc(100dvh - 150px);
}


.samples-tray {
    width: 45vw; 
    height: 100%; 
    background-color: #374151; 
    box-shadow: -2px 0 10px rgba(0,0,0,0.2); 
    display: flex;
    flex-direction: column;
    padding: 1rem;
    overflow-y: auto;
    user-select: none;
}
.samples-tray.visible {
/*    display: flex;*/
}

.toggle-samples-tray-button {
    width: 40px;
    height: 120px; 
    color: white;
    writing-mode: sideways-lr; 
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-top-left-radius: 0.5rem; 
    border-bottom-left-radius: 0.5rem;
    box-shadow: -2px 2px 5px rgba(0,0,0,0.1); 
    font-weight: 500;
    padding: 0.5rem 0; 
    border: 1px solid #4b5563;
    border-right: none; 
    pointer-events: auto; 
}
#toggleLongSamplesTrayButton {
    background-color: #065f46; /* Darker Green */
}
#toggleShortSamplesTrayButton {
    background-color: #075985; /* Darker Blue */
}


.samples-tray-label {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #e5e7eb;
    text-align: center;
}

.sample-category {
    margin-bottom: 1.5rem;
}
.sample-category h4 {
    font-size: 1rem;
    font-weight: 500;
    color: #9ca3af;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #4b5563;
    padding-bottom: 0.25rem;
}
.sample-item-card { 
    background-color: #4b5563;
    /* color: #e5e7eb; */
    color: #cbd5e1;
    padding: 0.75rem;
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 0.75rem;
}
.sample-item-card:hover {
    background-color: #525f71;
}
.sample-title {
    font-weight: bold;
    color: #cbd5e1;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.short-sample-item {
    background-color: #4b5563;
    padding: 0.75rem;
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
}
.short-sample-item:hover {
    background-color: #525f71;
}
.short-sample-title {
    font-weight: bold;
    color: #adf;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}
.short-sample-snippet {
    white-space: pre-wrap;
    font-family: monospace;
    color: #e5e7eb;
    font-size: 0.875rem;
}


/* Main Content Area Structure */
.main-content-wrapper { 
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding-right: calc(40px + 1rem); 
    width: 100%; 
    overflow: hidden; 
    min-height: 0; 
}
.app-header { 
    display: flex;
    justify-content: center; /* Center the title container */
    align-items: center;
    padding: 1rem 1rem 0.5rem 1rem; 
    flex-shrink: 0;
    position: relative;
}
.app-title-container {
    display: flex;
    align-items: center;
    justify-content: center;
}
.app-title {
    font-size: 1.5rem; 
    font-weight: 700; 
    color: #e5e7eb;
}
#infoButton {
    margin-left: 0.75rem;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
#infoButton:hover {
    color: #e5e7eb;
    background-color: #4b5563;
}


.main-content { 
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem 1rem 1rem; 
    overflow: hidden; 
    min-height: 0; 
}
.panels-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
    min-height: 0;
    /* max-width: 1800px; */
}
.panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #374151;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px 0 rgba(0,0,0,0.06);
    overflow: hidden; 
    min-height: 0; 
}
.input-panel { 
    position: relative;
    display: flex;
    flex-direction: column;
}
/* CodeMirror Customizations */
.CodeMirror {
    flex-grow: 1; 
    height: auto; 
    border-radius: 0.5rem;
    font-family: monospace;
    font-size: 0.875rem; /* Tailwind text-sm */
}
.cm-s-material-darker.CodeMirror { 
    background-color: #1e1f20; 
    color: #eef;
}
.cm-s-material-darker .cm-keyword { color: #C792EA; } 
.cm-s-material-darker .cm-atom { color: #F78C6C; } 
.cm-s-material-darker .cm-number { color: #e8a966; } 
.cm-s-material-darker .cm-def { color: #82AAFF; font-weight: bold; } 
.cm-s-material-darker .cm-variable { color: #EEFFFF; } 
.cm-s-material-darker .cm-variable-2 { color: #82AAFF; } 
.cm-s-material-darker .cm-variable-3, .cm-s-material-darker .cm-type { color: #FFCB6B; } 
.cm-s-material-darker .cm-property { color: #96bff9; } 
.cm-s-material-darker .cm-operator { color: #89DDFF; } 
.cm-s-material-darker .cm-comment { color: #546E7A; font-style: italic; } 
.cm-s-material-darker .cm-string { color: #e8a966; } 
.cm-s-material-darker .cm-string-2 { color: #f07178; } 
.cm-s-material-darker .cm-meta { color: #FFCB6B; } 
.cm-s-material-darker .cm-qualifier { color: #C3E88D; } 
.cm-s-material-darker .cm-builtin { color: #82AAFF; } 
.cm-s-material-darker .cm-bracket { color: #89DDFF; } 
.cm-s-material-darker .CodeMirror-matchingbracket { color: #EEFFFF; background-color: #3B515D; font-weight: bold; }
.cm-s-material-darker .CodeMirror-nonmatchingbracket { color: #FF5370; }

/* Custom highlighting for specific tokens */
.cm-custom-blue-tokens { color: #7fa5f3; font-weight: bold; }
.cm-custom-red-tokens { color: #db6c4f; font-weight: bold; }
.cm-custom-purple-tokens { color: #c9abf9; font-weight: bold; }
.cm-custom-orange-tokens { color: #e8a951; }


.CodeMirror-scroll {
        min-height: 100px; 
        border-radius: 0.5rem;
}

.history-buttons-container {
    position: absolute;
    bottom: 0.75rem;
    right: 0.75rem; 
    display: flex;
    gap: 0.25rem; 
    z-index: 20; 
}
.history-button {
    background-color: #6b7280; 
    color: #e5e7eb; 
    border: none;
    border-radius: 0.375rem; 
    padding: 0.2rem 0.5rem; 
    font-size: 1rem; 
    font-weight: bold; 
    line-height: 1; 
    cursor: pointer;
    width: 2rem; 
    height: 1.75rem; 
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
}
.history-button:hover:not(:disabled) {
    background-color: #4b5563; 
}
.history-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.share-button-container {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem; 
    display: flex;
    gap: 0.25rem; 
    z-index: 20; 
}
.share-image {
    width: 2rem; 
    height: 1.75rem;
}
.share-success-msg {
    background-color: #065f46;
    border-radius: 0.375rem; 
    font-size: 0.9rem; 
    padding: 0.1rem;
    height: 1.6rem;
    margin-top: 0.1rem;
}



.output-panel {
    display: flex; 
    flex-direction: column; 
    min-height: 0;
    flex: 0.8;
}
.output-content-area {
    background-color: #262626;
    font-family: monospace;
    font-size: large;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    position: relative;
    flex-grow: 1; 
    padding: 0.75rem;
    color: #e5e7eb;
    border-top-left-radius: 0.5rem;
    border-top-right-radius: 0.5rem;
    border-bottom-left-radius: 0; 
    border-bottom-right-radius: 0; 
    min-height: 0; 
}
.output-content-area:empty::before {
    content: attr(placeholder);
    color: #6b7280;
    position: absolute;
    left: 0.75rem;
    top: 0.75rem;
    pointer-events: none;
}
#outputInfoBar {
    background-color: #4b5563; 
    color: #d1d5db; 
    padding: 0.25rem 0.75rem; 
    font-size: 0.8rem; 
    font-family: monospace;
    border-bottom-left-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
    text-align: right;
    flex-shrink: 0; 
}


.controls-container {
    margin-top: 1rem; 
    flex-shrink: 0; 
    position: relative; 
}
#takingTooLongPopup {
    position: absolute;
    bottom: 100%; 
    left: 50%;
    transform: translateX(-50%);
    background-color: #f59e0b; 
    color: #1f2937; 
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    display: none; 
    white-space: nowrap;
}
#takingTooLongPopup:hover {
    background-color: #d97706; 
}

.apply-button, .stop-button, .python-loading-message { 
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 500;
    transition: background-color 0.2s, opacity 0.2s;
    border: 1px solid transparent;
    cursor: pointer;
    text-align: center;
    width: 100%;
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.apply-button {
    background-color: #10b981;
    color: white;
}
.apply-button:hover {
    background-color: #059669;
}
.apply-button:disabled, .stop-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.stop-button {
    background-color: #ef4444;
    color: white;
}
.stop-button:hover:not(:disabled) {
    background-color: #dc2626;
}
.stop-button svg {
    margin-right: 0.5rem;
}
.python-loading-message {
    background-color: #777;
    color: white;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000; 
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}
.modal-content {
    background-color: #2d3748; 
    color: #e2e8f0; 
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}
.modal-content p {
    margin-bottom: 1rem;
    line-height: 1.6;
}
.modal-content h3 {
    font-size: 1.25rem; 
    font-weight: 600; 
    margin-bottom: 1rem;
}
.modal-button {
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    border: none;
}
.modal-button.close-dialog {
    background-color: #a0aec0; 
    color: #1a202c; 
    margin-left: auto; 
}
.modal-button.close-dialog:hover {
    background-color: #718096; 
}


.message-box-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.7); display: flex;
    justify-content: center; align-items: center; z-index: 10000;
    opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease;
}
.message-box-overlay.show { opacity: 1; visibility: visible; }
.message-box {
    background-color: #374151; color: #d1d5db;
    padding: 1.5rem; border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3), 0 4px 6px -2px rgba(0,0,0,0.25);
    text-align: center; max-width: 90%; width: 300px;
}
.message-box p { margin-bottom: 1rem; }
.message-box button {
    background-color: #3b82f6; color: white; padding: 0.5rem 1rem;
    border-radius: 0.375rem; border: none; cursor: pointer;
}
.message-box button:hover { background-color: #2563eb; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #374151; border-radius: 0.5rem; }
::-webkit-scrollbar-thumb { background: #6b7280; border-radius: 0.5rem; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }