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

body {
    font-family: system-ui, sans-serif;
    background: #1a1a1a;
    color: #e0e0e0;
    line-height: 1.5;
}

main {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

h1 {
    font-size: 1.5rem;
}

label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: #aaa;
}

textarea,
input,
select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #444;
    background: #252525;
    color: #e0e0e0;
    font: inherit;
    font-size: 0.875rem;
}

textarea:focus,
input:focus,
select:focus {
    outline: none;
    border-color: #4a9eff;
}

input.invalid {
    border-color: #c44;
    background: #2a2020;
}

textarea {
    font-family: monospace;
    resize: vertical;
    min-height: 150px;
}

button {
    padding: 0.5rem 1rem;
    border: 1px solid #444;
    background: #333;
    color: #e0e0e0;
    font: inherit;
    cursor: pointer;
}

button:hover {
    background: #444;
}

.btn-primary {
    background: #4a9eff;
    border-color: #4a9eff;
    color: #000;
}

.btn-primary:hover {
    background: #3a8eef;
}

.btn-clear {
    background: transparent;
    border: none;
    color: #888;
}

.btn-clear:hover {
    color: #e0e0e0;
}

/* Expression section */
.expression-section {
    margin-bottom: 1rem;
}

.eval-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

#result {
    flex: 1;
    padding: 0.5rem 1rem;
    background: #252525;
    font-family: monospace;
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

#result.success {
    background: #1a2e1a;
}

#result.error {
    background: #2e1a1a;
    color: #f88;
}

#result.warning {
    background: #2e2a1a;
}

.placeholder {
    color: #666;
    font-family: system-ui, sans-serif;
}

.result-type {
    font-family: system-ui, sans-serif;
    font-size: 0.75rem;
    color: #888;
    margin-left: 0.5rem;
}

.result-hint {
    width: 100%;
    font-family: system-ui, sans-serif;
    font-size: 0.75rem;
    color: #888;
    margin-top: 0.25rem;
}

/* Variables section */
.variables-section {
    margin-top: 2rem;
}

.variables-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.variables-header label {
    margin-bottom: 0;
}

.variables-actions {
    display: flex;
    gap: 0.5rem;
}

.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: #333;
    border: 1px solid #444;
    display: none;
    flex-direction: column;
    z-index: 100;
}

.dropdown-menu.open {
    display: flex;
}

.dropdown-menu button {
    text-align: left;
    white-space: nowrap;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid #333;
}

th {
    font-size: 0.75rem;
    font-weight: 600;
    color: #888;
    background: #222;
}

td:nth-child(1) {
    width: 20%;
}

td:nth-child(2) {
    width: 15%;
}

td:nth-child(3) {
    width: 60%;
}

td:nth-child(4) {
    width: 5%;
    text-align: center;
}

.var-name {
    font-family: monospace;
}

.var-type {
    width: 100%;
}

.var-remove {
    padding: 0.25rem 0.5rem;
    color: #c66;
    border: none;
    background: none;
}

.var-remove:hover {
    background: #3a2020;
}

.var-val input {
    width: 100%;
}

.options-input {
    margin-bottom: 0.5rem;
    font-family: monospace;
}

.options-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.opt {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: #333;
    cursor: pointer;
}

.opt:hover {
    background: #444;
}

.opt.selected {
    background: #1a3a5a;
}

.opt label {
    cursor: pointer;
    font-size: 0.875rem;
}

.field-error {
    color: #f66;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

#variables:empty::after {
    content: 'Ingen variabler oprettet. Klik "Tilføj" for at oprette en.';
    display: block;
    padding: 1rem;
    color: #666;
    font-size: 0.875rem;
}

/* Header buttons */
.header-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-info {
    width: 2rem;
    height: 2rem;
    padding: 0;
    border-radius: 50%;
    font-weight: bold;
    font-size: 1rem;
    background: #333;
    border: 1px solid #555;
}

.btn-info:hover {
    background: #444;
    border-color: #666;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    right: -500px;
    width: 500px;
    max-width: 90vw;
    height: 100vh;
    background: #222;
    border-left: 1px solid #444;
    transition: right 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    right: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #444;
    background: #1a1a1a;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.btn-close {
    width: 2rem;
    height: 2rem;
    padding: 0;
    font-size: 1.5rem;
    line-height: 1;
    background: transparent;
    border: none;
    color: #888;
}

.btn-close:hover {
    color: #fff;
    background: transparent;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.sidebar-content section {
    margin-bottom: 2rem;
}

.sidebar-content section:last-child {
    margin-bottom: 0;
}

.sidebar-content h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #4a9eff;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #333;
}

.sidebar-content p {
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: #ccc;
}

.sidebar-content ul {
    margin: 0.5rem 0 0.75rem 1.5rem;
    font-size: 0.9rem;
    color: #ccc;
}

.sidebar-content li {
    margin-bottom: 0.25rem;
}

.sidebar-content code {
    background: #333;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.85em;
    color: #f0f0f0;
}

.sidebar-content strong {
    color: #fff;
}

/* Sidebar overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 999;
}

.sidebar-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* Autocomplete */
.autocomplete-dropdown {
    position: fixed;
    background: #2a2a2a;
    border: 1px solid #444;
    max-height: 160px;
    overflow-y: auto;
    display: none;
    z-index: 1000;
    min-width: 180px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.autocomplete-dropdown.open { display: block; }

.autocomplete-item {
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: monospace;
    font-size: 0.875rem;
}

.autocomplete-item:hover, .autocomplete-item.selected { background: #3a3a3a; }

.autocomplete-icon { width: 1.2em; text-align: center; font-style: normal; }
.autocomplete-icon.fn { color: #b48ead; }
.autocomplete-icon.text { color: #4a9eff; }
.autocomplete-icon.number { color: #8fbf7f; }
.autocomplete-icon.date { color: #d08770; }
.autocomplete-icon.choice { color: #ebcb8b; }
.autocomplete-icon.option { color: #888; }