:root {
    --bg: #fafafa;
    --card-bg: #ffffff;
    --text: #333333;
    --border: #e0e0e0;
    --primary: #222222;
    --primary-hover: #000000;
    --accent: #2563eb;
    --danger: #dc2626;
    --radius: 5px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    overflow-x: hidden;
}

nav {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

nav .brand { font-weight: 700; font-size: 1.2rem; }
nav a { color: var(--text); text-decoration: none; font-size: 0.9rem; margin-left: 20px; }
nav a:hover { text-decoration: underline; }

.container { max-width: 100%; margin: 0; padding: 1rem; }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

h2, h3 { margin-top: 0; font-weight: 600; }

input[type="text"], input[type="number"], input[type="email"], select, textarea {
    width: 100%;
    padding: 10px;
    margin: 5px 0 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-sizing: border-box;
    font-size: 0.9rem;
    font-family: inherit;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

button, .btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 10px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.2s ease;
    font-weight: 500;
}

button:hover, .btn:hover { 
    background: var(--primary-hover); 
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

button:active, .btn:active {
    transform: translateY(0);
}

button:disabled { 
    background: #999; 
    cursor: not-allowed; 
    transform: none;
    box-shadow: none;
}

code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.editor-container { 
    display: grid; 
    grid-template-columns: 280px 1fr; 
    gap: 15px; 
    height: calc(100vh - 60px);
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    max-width: 100vw;
    width: 100vw;
}

.sidebar { 
    overflow-y: auto; 
    height: 100%;
    padding: 15px 10px 15px 15px;
    background: var(--bg);
}

.canvas-container { 
    background: #f5f5f5; 
    display: flex; 
    align-items: flex-start;
    justify-content: center;
    overflow: auto;
    padding: 15px;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
}

#canvasWrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
}

canvas { 
    background: white; 
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    border-radius: 4px;
    max-width: 100%;
    height: auto;
    display: block;
    cursor: move;
}

/* Loading Spinner */
.spinner {
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top: 2px solid white;
    width: 14px;
    height: 14px;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    display: none;
}
button.loading .spinner, .btn.loading .spinner { display: inline-block; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Sidebar scrollbar */
.sidebar::-webkit-scrollbar {
    width: 8px;
}
.sidebar::-webkit-scrollbar-track {
    background: var(--bg);
}
.sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Better input file styling */
input[type="file"] {
    padding: 8px;
    font-size: 0.85rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    background: var(--bg);
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

input[type="file"]:hover {
    border-color: var(--primary);
}

input[type="file"]::file-selector-button {
    padding: 6px 12px;
    border: none;
    background: var(--primary);
    color: white;
    border-radius: 3px;
    cursor: pointer;
    margin-right: 10px;
    font-size: 0.8rem;
}

input[type="file"]::file-selector-button:hover {
    background: var(--primary-hover);
}

/* Card improvements */
.card h3 {
    color: var(--primary);
    font-size: 1rem;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--accent);
}