:root {
    --bg-dark: #1e1e1e;
    --bg-panel: #252526;
    --bg-hover: #2a2d2e;
    --border: #3e3e42;
    --accent: #007acc;
    --text-main: #cccccc;
    --text-muted: #858585;
    --canvas-bg: #121212;
}

* {
    box-sizing: border-box;
    user-select: none;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

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

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

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

#app-container {
    display: grid;
    /* Column 1: Canvas area (flex), Column 2: Sidebar (fixed) */
    grid-template-columns: 1fr 250px;
    /* Row 1: Toolbar, Row 2: Canvas, Row 3: Command Bar */
    grid-template-rows: 50px 1fr 30px;
    height: 100vh;
    width: 100vw;
}

/* Toolbar (Top Horizontal) */
#toolbar {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: row; /* Horizontal */
    align-items: center;
    padding: 0 10px;
    overflow-x: auto; /* Scroll horizontally */
    overflow-y: hidden;
    white-space: nowrap;
}

.tool-group {
    display: flex;
    flex-direction: row; /* Items side-by-side */
    align-items: center;
    border-right: 1px solid var(--border); /* Separator */
    border-bottom: none;
    padding-right: 10px;
    margin-right: 10px;
    margin-bottom: 0;
    height: 100%;
}

.tool-group:last-child {
    border-right: none;
}

.category-label {
    display: none; /* Hide labels to save space in horizontal view */
}

.tool-btn {
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin: 0 2px;
}

.tool-btn:hover {
    background-color: var(--bg-hover);
}

.tool-btn.active {
    background-color: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}

.tool-btn.logged-in {
    color: #4caf50;
}

/* Canvas Wrapper */
#canvas-wrapper {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
    position: relative; /* For absolute positioning of coords */
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#cad-canvas {
    background-color: var(--canvas-bg);
    cursor: crosshair;
    width: 100%;
    height: 100%;
    display: block;
}

/* Sidebar (Right) */
#sidebar {
    grid-column: 2 / 3;
    grid-row: 1 / 3; /* Span Top and Middle */
    background-color: var(--bg-panel);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 10; /* Ensure it stays above if needed */
}

.panel-header {
    padding: 10px;
    background-color: #2d2d30;
    font-weight: 600;
    font-size: 12px;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 1px;
    height: 50px; /* Match toolbar height for alignment */
    display: flex;
    align-items: center;
}

#properties-content {
    padding: 15px;
    font-size: 12px;
}

.prop-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.prop-row label {
    color: var(--text-muted);
}

.prop-row input {
    background-color: #1e1e1e;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 4px 8px;
    border-radius: 2px;
    width: 60%;
    font-family: 'JetBrains Mono', monospace;
}

.prop-row input:focus {
    border-color: var(--accent);
    outline: none;
}

.instruction {
    margin-top: 10px;
    padding: 10px;
    background-color: rgba(0, 122, 204, 0.1);
    border-left: 3px solid var(--accent);
    color: var(--text-main);
    line-height: 1.4;
}

/* Command Bar */
#command-bar {
    grid-column: 1 / -1;
    grid-row: 3 / 4;
    background-color: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    padding: 0 15px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

#coords-display {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background-color: rgba(30, 30, 30, 0.8);
    padding: 5px 10px;
    border-radius: 4px;
    pointer-events: none;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-muted);
}

.cmd-prompt {
    margin-right: 10px;
    font-weight: bold;
}

#cmd-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: white;
    font-family: inherit;
    font-size: inherit;
    outline: none;
}

#cmd-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: var(--bg-panel);
    margin: 15% auto;
    padding: 20px;
    border: 1px solid var(--border);
    width: 300px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: white;
    text-decoration: none;
    cursor: pointer;
}

.file-list-item {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.file-list-item:hover {
    background-color: #333;
}

/* Horizontal Tool Group Override (Legacy support, can be removed if not used elsewhere) */
.horizontal-group {
    flex-direction: row;
    flex-wrap: nowrap; /* Prevent wrapping in main toolbar */
    justify-content: flex-start;
}

/* Branding Logo */
#branding-logo {
    margin-top: auto;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-top: 1px solid var(--border);
    background-color: var(--bg-dark);
}

#branding-logo img {
    max-width: 100%;
    max-height: 80px;
    opacity: 0.8;
    transition: opacity 0.3s;
}

#branding-logo img:hover {
    opacity: 1;
}