body, html {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: 'maria', serif;
    color: #333;
    background-color: #ede8db;
}

@font-face {
    font-family: 'maria';
    src: url('fonts/maria.woff2') format('woff2'),
         url('fonts/maria.woff') format('woff'),
         url('fonts/maria.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'D2Coding';
    src: url('fonts/D2Coding.woff2') format('woff2'),
         url('fonts/D2Coding.woff') format('woff'),
         url('fonts/D2Coding.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* CodeMirror */
.CodeMirror {
    height: 100%;
    font-family: 'D2Coding', monospace;
    font-size: 14px;
    line-height: 1.2;
    background: transparent;
    color: #333;
}

.CodeMirror-focused .CodeMirror-cursor {
    border-left: 1px solid #333;
}

.CodeMirror-lines {
    padding: 8px;
}

.CodeMirror-line .cm-comment {
    color: #6272a4 !important;
}

#codeEditor .CodeMirror .CodeMirror-linenumber {
    color: #8a7e66;
    text-align: right !important;
    padding: 0 8px 0 4px !important;
    min-width: 32px !important;
    width: auto !important;
    box-sizing: border-box;
}

#codeEditor .CodeMirror .CodeMirror-gutters {
    background-color: #f8f5f0;
    border-right: 1px solid #e0d9c8;
    width: auto !important;
    min-width: 40px !important;
}

/* LOT Syntax Highlighting */
.CodeMirror .cm-comment {
    color: #9f9f9f!important;
}

.CodeMirror .cm-separator {
    color: navy !important;
    font-weight: 900;
}

.CodeMirror .cm-bracket {
    color: navy !important;
    font-weight: 600;
}

.CodeMirror .cm-operator {
    color: #ff5555 !important;
    font-weight: 600;
}

.CodeMirror .cm-domain-keyword {
    color: #b5338a !important;
}

.CodeMirror .cm-constraint-keyword {
    color: #6f2da8 !important;
}

.CodeMirror .cm-constraint-header {
    color: black !important;
    font-weight: 600;
}

.CodeMirror .cm-number {
    color: #f4bb44 !important;
    font-weight: 600;
}

.CodeMirror .cm-range-notation {
    color: #f4bb44 !important;
    font-weight: 600;
}

.CodeMirror .cm-preference-marker {
    color: #ff5555 !important;
    font-weight: 600;
}

.CodeMirror .cm-punctuation {
    color: navy !important;
    font-weight: 600;
}

/* Editor */
.editor-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: calc(100vh - 80px);
    display: grid;
    place-items: center;
    z-index: 1;
}

.editor-wrapper {
    width: 90%;
    max-width: 800px;
    height: 90%;
    position: relative;
    border: 1px solid #8a7e66;
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.95);
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.editor-header {
    background-color: #f5f2e9;
    border-bottom: 1px solid #e0d9c8;
    padding: 8px 12px;
    font-size: 13px;
    color: #8a7e66;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 10;
}

.header-actions {
    display: flex;
    gap: 15px;
}

.header-link {
    color: #8a7e66;
    cursor: pointer;
    font-size: 13px;
    transition: color 0.2s;
    user-select: none;
}

.header-link:hover {
    color: #5a5346;
    text-decoration: none;
}

.editor-main {
    display: flex;
    height: calc(100% - 35px);
}

.line-numbers {
    background-color: #f8f5f0;
    border-right: 1px solid #e0d9c8;
    padding: 10px 8px;
    font-family: 'D2Coding', monospace;
    font-size: 14px;
    line-height: 1.2;
    color: #8a7e66;
    text-align: right;
    user-select: none;
    min-width: 30px;
    white-space: pre;
    overflow-y: hidden;
}

#codeEditor {
    flex: 1;
    height: 100%;
}

#codeEditor .CodeMirror {
    height: 100%;
    border: none;
    background: transparent;
    font-family: 'D2Coding', monospace;
    font-size: 14px;
    line-height: 1.2;
    color: #333;
}

#codeEditor .CodeMirror-focused {
    outline: none;
}

#codeEditor .CodeMirror .CodeMirror-lines {
    padding: 10px;
}

.drop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(138, 126, 102, 0.05);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: opacity 0.3s ease;
    cursor: text;
}

.drop-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.drop-overlay.drag-active {
    background-color: rgba(138, 126, 102, 0.1);
}

.drop-message {
    color: #8a7e66;
    font-size: 16px;
    text-align: center;
    user-select: none;
}

.status-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(245, 242, 233, 0.95);
    border-top: 1px solid rgba(138, 126, 102, 0.2);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 10;
    backdrop-filter: blur(10px);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 8px;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid rgba(138, 126, 102, 0.1);
    max-width: 800px;
    margin: 0 auto;
    width: 98%;
    box-sizing: border-box;
}

.status-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #8a7e66;
}

.status-indicator.ready {
    background-color: #8a7e66;
}

.status-indicator.running {
    background-color: #f39c12;
    animation: pulse 1.5s infinite;
}

.status-indicator.success {
    background-color: #27ae60;
}

.status-indicator.error {
    background-color: #e74c3c;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.panel-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn {
    background-color: #8a7e66;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-family: 'maria', serif;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    background-color: #5a5346;
}

.btn:disabled {
    background-color: #bbb;
    cursor: not-allowed;
}

.btn.secondary {
    background-color: transparent;
    color: #8a7e66;
    border: 1px solid #8a7e66;
}

.btn.secondary:hover {
    background-color: #8a7e66;
    color: white;
}

.expand-toggle {
    padding: 4px;
    background-color: rgba(138, 126, 102, 0.1);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s;
}

.expand-toggle.expanded {
    transform: rotate(180deg);
}

.panel-content.expanded {
    max-height: 60vh;
    padding: 10px 0;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.panel-content.maximized {
    max-height: 85vh !important;
    height: 85vh !important;
}

.panel-content.maximized .table-wrapper {
    height: calc(85vh - 100px) !important;
    max-height: calc(85vh - 100px) !important;
}

.panel-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.01s ease, padding 0.01s ease;
    margin: 0 auto;
    max-width: 800px;
    width: 90%;
}

.tab-download {
    padding: 8px 12px;
    background-color: #f8f5f0;
    border: 1px solid #e0d9c8;
    border-bottom: none;
    cursor: pointer;
    font-size: 14px;
    color: #8a7e66;
    transition: all 0.2s;
    margin-left: auto;
}

.tab-download:hover {
    background-color: #e0d9c8;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #8a7e66;
    border-radius: 50%;
    border-top-color: transparent;
    margin-right: 8px;
    vertical-align: middle;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.params-form {
    display: flex;
    align-items: center;
    gap: 40px;
    margin-bottom: 8px;
    justify-content: start;
}

.param-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.param-label {
    font-size: 13px;
    color: #5a5346;
    font-weight: 500;
    white-space: nowrap;
}

.param-input {
    padding: 4px 8px;
    border: 1px solid #e0d9c8;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.8);
    font-family: 'maria', serif;
    font-size: 13px;
    color: #333;
    margin: 4px;
    width: 60px;
    text-align: center;
    -moz-appearance: textfield;
}

.param-input::-webkit-outer-spin-button,
.param-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.error-message {
    background-color: #ffeaea;
    border: 1px solid #ffcdd2;
    border-radius: 4px;
    padding: 12px;
    color: #c62828;
    font-family: 'D2Coding', monospace;
    font-size: 14px;
    margin: 8px;
    white-space: pre;
}

/* Spreadsheet Display */
.spreadsheet-tabs {
    display: flex;
    border-bottom: 1px solid #e0d9c8;
    margin-bottom: 15px;
    overflow-x: auto;
}

.tab {
    padding: 8px 16px;
    background-color: #f8f5f0;
    border: 1px solid #e0d9c8;
    border-bottom: none;
    cursor: pointer;
    font-size: 14px;
    color: #8a7e66;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab.active {
    background-color: white;
    color: #333;
    border-bottom: 1px solid white;
    margin-bottom: -1px;
}

.spreadsheet-container {
    background-color: white;
    border: 1px solid #e0d9c8;
    border-radius: 4px;
    overflow: hidden;
}

.sheet-content {
    display: none;
}

.sheet-content.active {
    display: block;
}

.sheet-header {
    background-color: #f8f5f0;
    padding: 10px 15px;
    border-bottom: 1px solid #e0d9c8;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sheet-title {
    font-weight: 500;
    color: #333;
}

.sheet-actions {
    display: flex;
    gap: 8px;
}

.table-wrapper {
    overflow: auto;
    max-height: 40vh;
    height: 40vh;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-family: 'maria', serif;
    white-space: nowrap;
}

.data-table th,
.data-table td {
    padding: 4px 8px;
    border: 1px solid #e0d9c8;
    text-align: left;
    white-space: nowrap;
}

.data-table th {
    background-color: #f8f5f0;
    font-weight: 600;
    color: #5a5346;
    position: sticky;
    top: 0;
}

.data-table tr:nth-child(even) {
    background-color: #fafafa;
}

@media screen and (max-width: 768px) {
    .panel-header {
        width: 98%;
        padding: 12px 8px;
    }

    .status-info {
        flex-shrink: 0;
    }

    .panel-controls {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .btn {
        white-space: nowrap;
        flex-shrink: 0;
    }

    .panel-content {
        width: 98%;
        padding: 4px 8px;
    }

    .params-form {
        gap: 15px;
        padding: 4px;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .param-group {
        min-width: 0;
        flex-shrink: 0;
        white-space: nowrap;
    }

    .param-label {
        font-size: 13px;
    }

    .param-input {
        border: 1px solid #e0d9c8;
        border-radius: 4px;
        background-color: rgba(255, 255, 255, 0.8);
        font-family: 'maria', serif;
        font-size: 13px;
        color: #333;
        padding: 4px 8px;
        width: 40px;
        margin: 0px;
        text-align: center;
        -moz-appearance: textfield;
    }

    .panel-content.maximized {
        max-height: 65vh !important;
        height: 65vh !important;
    }

    .panel-content.maximized .table-wrapper {
        height: calc(65vh - 100px) !important;
        max-height: calc(65vh - 100px) !important;
    }
}
