:root {
    --bg-app: #09090b;
    --bg-panel: #18181b;
    --bg-elevated: #27272a;
    --bg-input: #09090b;

    --text-main: #f4f4f5;
    --text-muted: #a1a1aa;

    --border: #27272a;
    --border-focus: #52525b;

    --accent-base: #8b5cf6;
    --accent-hover: #7c3aed;
    --accent-gradient: linear-gradient(135deg, #8b5cf6, #3b82f6);

    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --warning: #f59e0b;

    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'Fira Code', monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

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

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

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.brand {
    height: 64px;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-main);
}

.brand-icon {
    color: var(--accent-base);
    display: flex;
}

.endpoints-header {
    padding: 1.5rem 1rem 0.5rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.endpoints-header h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.endpoint-list {
    list-style: none;
    overflow-y: auto;
    padding: 0.5rem;
    flex-grow: 1;
}

.ep-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.ep-item:hover {
    background: var(--bg-elevated);
}

.ep-item.active {
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.3);
}

.ep-method {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    width: 50px;
    text-align: center;
    color: #fff;
}

.ep-method.GET {
    background: #3b82f6;
}

.ep-method.POST {
    background: #10b981;
}

.ep-method.PUT,
.ep-method.PATCH {
    background: #f59e0b;
}

.ep-method.DELETE {
    background: #ef4444;
}

.ep-route {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--font-mono);
}

/* Base Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-sans);
    font-weight: 500;
    border: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.btn.icon-btn {
    background: transparent;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 4px;
}

.btn.icon-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-main);
}

.btn.primary {
    background: var(--text-main);
    color: var(--bg-app);
}

.btn.primary:hover {
    background: #d4d4d8;
}

.btn.primary.lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn.sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.btn.danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn.danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Workspace */
.workspace {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--bg-app);
}

.empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.empty-state.active {
    opacity: 1;
    pointer-events: auto;
}

.empty-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.1);
    color: var(--accent-base);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.empty-state h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 2rem;
    max-width: 400px;
    line-height: 1.5;
}

.designer-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.designer-view.active {
    opacity: 1;
    pointer-events: auto;
}

/* Route Builder Header */
.designer-header {
    height: 80px;
    padding: 0 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-panel);
}

.route-builder {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    width: 100%;
    max-width: 600px;
    transition: border-color 0.2s;
}

.route-builder:focus-within {
    border-color: var(--accent-base);
}

.select-method {
    appearance: none;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-weight: 700;
    font-family: var(--font-mono);
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    outline: none;
}

.select-method[data-method="GET"] {
    color: #3b82f6;
}

.select-method[data-method="POST"] {
    color: #10b981;
}

.select-method[data-method="PUT"],
.select-method[data-method="PATCH"] {
    color: #f59e0b;
}

.select-method[data-method="DELETE"] {
    color: #ef4444;
}

.select-method option {
    background: var(--bg-panel);
    color: var(--text-main);
}

.route-prefix {
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-left: 0.5rem;
}

.input-route {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 1rem;
    width: 100%;
    outline: none;
}

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

/* Panels Grid */
.panels-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex-grow: 1;
    min-height: 0;
}

.panel {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
}

.panel:last-child {
    border-right: none;
}

.panel-header {
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.panel-header.glass {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.05), transparent);
}

.panel-body {
    padding: 2rem;
    overflow-y: auto;
    flex-grow: 1;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-content: start;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

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

input[type="number"],
input[type="text"] {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    font-family: var(--font-sans);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    outline: none;
    transition: border 0.2s;
}

input[type="number"]:focus {
    border-color: var(--accent-base);
}

.code-editor {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: #a6e22e;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 1rem;
    border-radius: var(--radius-sm);
    outline: none;
    resize: vertical;
    min-height: 300px;
    line-height: 1.5;
    transition: border 0.2s;
}

.code-editor.sm {
    min-height: 150px;
}

.code-editor:focus {
    border-color: var(--accent-base);
}

/* Test Console */
.console-body {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.test-config {
    background: var(--bg-panel);
    border: 1px dashed var(--border-focus);
    padding: 1.5rem;
    border-radius: var(--radius-md);
}

.test-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    background: var(--border);
}

.mono-text {
    font-family: var(--font-mono);
    color: var(--text-main);
    word-break: break-all;
}

.test-results {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.result-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    border-bottom: none;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.result-meta {
    display: flex;
    gap: 0.75rem;
}

.result-meta.hidden {
    display: none;
}

.status-badge,
.time-badge {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: #fff;
}

.status-badge.success {
    background: var(--success);
}

.status-badge.error {
    background: var(--danger);
}

.status-badge.warn {
    background: var(--warning);
}

.time-badge {
    background: var(--border-focus);
}

.result-window {
    border: 1px solid var(--border);
    background: #000;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    flex-grow: 1;
    min-height: 300px;
    position: relative;
    overflow: auto;
    padding: 1rem;
}

.idle-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
}

.idle-text.hidden {
    display: none;
}

.code-output {
    color: #e5e7eb;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-wrap;
    margin: 0;
}

.code-output.hidden {
    display: none;
}

/* Spinner */
.spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-base);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner.hidden {
    display: none;
}

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

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-app);
}

::-webkit-scrollbar-thumb {
    background: var(--border-focus);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}