:root {
    --bg-main: #0D1117;
    /* Deep background */
    --bg-panel: #161B22;
    /* Slightly lighter for panels */
    --bg-input: #010409;
    /* Darker for inputs/pre */

    --primary: #6C5CE7;
    /* Accent Slate Blue */
    --primary-hover: #5A4BDE;

    --text-main: #C9D1D9;
    --text-muted: #8B949E;

    --border: #30363D;
    --border-focus: #6C5CE7;

    --radius: 12px;
    --radius-sm: 6px;

    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    font-size: 14px;
}

/* Layout */
.app-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: rgba(22, 27, 34, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-main);
}

.brand h1 {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.brand svg {
    color: var(--primary);
}

.actions {
    display: flex;
    gap: 0.75rem;
}

.workspace {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* Panels */
.panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Prevents flex flex-basis blowout */
}

.editor-panel {
    border-right: 1px solid var(--border);
    background: var(--bg-panel);
}

.preview-panel {
    background: var(--bg-main);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: rgba(22, 27, 34, 0.5);
}

.panel-header h2 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}

/* Editor Body */
.editor-body {
    flex: 1;
    display: flex;
    position: relative;
}

.monospaced-input {
    flex: 1;
    background: var(--bg-input);
    color: var(--text-main);
    border: none;
    padding: 1.5rem;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.5;
    resize: none;
    outline: none;
}

.monospaced-input::placeholder {
    color: #484F58;
}

/* Settings Bar */
.settings-bar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 1.5rem;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.setting-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.setting-group label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.input-element {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238B949E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1rem;
    transition: border-color 0.2s;
}

.input-element:focus {
    border-color: var(--primary);
}

/* Segmented Control */
.segmented-control {
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.segment {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.segment:hover {
    color: var(--text-main);
}

.segment.active {
    background: var(--border);
    color: var(--text-main);
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input {
    display: none;
}

.custom-check {
    width: 1rem;
    height: 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background: var(--bg-input);
}

.checkbox-label input:checked+.custom-check {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-label input:checked+.custom-check::after {
    content: '';
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

/* Button */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

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

.btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn.ghost {
    background: transparent;
    color: var(--text-main);
    border-color: var(--border);
}

.btn.ghost:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Preview */
.preview-body {
    flex: 1;
    position: relative;
    overflow: auto;
    padding: 1.5rem;
}

#output-block {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--text-main);
    white-space: pre;
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
    opacity: 1;
    transition: opacity 0.3s;
}

.empty-state.hidden {
    opacity: 0;
    pointer-events: none;
}

.empty-state svg {
    color: var(--border);
}

.badge {
    background: var(--bg-input);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.toast {
    font-size: 0.75rem;
    color: #2EA043;
    opacity: 0;
    transition: opacity 0.3s;
    font-weight: 500;
}

.toast.show {
    opacity: 1;
}

@media (max-width: 768px) {
    .workspace {
        flex-direction: column;
    }

    .editor-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
        flex: 0 0 50%;
    }
}