:root {
    --bg-color: #f0f0f0;
    --grid-color: rgba(0, 0, 0, 0.1);
    --node-bg: #ffffff;
    --node-border: #cccccc;
    --node-selected: #007bff;
    --text-color: #333333;
    --text-muted: #888888;
    --danger: #dc3545;
    --pane-bg: #ffffff;
    --shadow: 0 2px 5px rgba(0,0,0,0.2);
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
}

#grid-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(var(--grid-color) 1px, transparent 1px);
    background-size: 20px 20px;
    z-index: -1;
    pointer-events: none;
}

#canvas-container {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: relative;
    contain: content;
}

#tree-container {
    position: absolute;
    transform-origin: 0 0;
    will-change: transform;
    width: 0;
    height: 0;
    pointer-events: none;
}

#node-layer, #connector-layer {
    pointer-events: auto;
}

#connector-layer {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

.connector {
    fill: none;
    stroke: #999;
    stroke-width: 1.5;
}

#node-layer {
    position: absolute;
    top: 0;
    left: 0;
}

.node {
    position: absolute;
    padding: 10px 20px;
    background: var(--node-bg);
    border: 1px solid var(--node-border);
    border-radius: 20px;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    font-size: 18px;
    transition: box-shadow 0.2s, border-color 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.node:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.node.selected {
    border-color: var(--node-selected);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.node.complete {
    text-decoration: line-through;
    color: var(--text-muted);
    background-color: #f8f8f8;
}

.node.has-notes {
    border-left: 4px solid #28a745;
}

/* UI Overlays */
.ui-overlay {
    position: fixed;
    z-index: 100;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(240, 240, 240, 0.8);
    border-radius: 8px;
}

.top-left { top: 10px; left: 10px; }
.bottom-right { bottom: 10px; right: 10px; }

.divider {
    width: 1px;
    height: 24px;
    background: #ccc;
    margin: 0 5px;
}

button {
    padding: 10px 16px;
    cursor: pointer;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
}

button:hover { background: #f0f0f0; }
button:disabled { color: #ccc; cursor: not-allowed; }

button.danger { color: var(--danger); border-color: var(--danger); }
button.danger:hover { background: #fff5f5; }

/* Details Pane */
#details-pane {
    position: fixed;
    right: 0;
    top: 0;
    width: 20%;
    min-width: 250px;
    height: 100%;
    background: var(--pane-bg);
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

#details-pane.hidden {
    transform: translateX(100%);
}

.pane-header {
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pane-header h3 { margin: 0; }

.pane-content {
    padding: 15px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.pane-content label { font-weight: bold; font-size: 14px; color: #666; }

.pane-content input[type="text"], 
.pane-content textarea {
    width: 100%;
    padding: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 18px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
}

.checkbox-row input[type="checkbox"] {
    width: 24px;
    height: 24px;
}

.checkbox-row label {
    font-size: 18px;
    cursor: pointer;
}

.actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 300;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal.hidden { display: none; }

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

#md-text {
    width: 100%;
    font-family: monospace;
    padding: 10px;
    box-sizing: border-box;
}

/* Radial Menu */
.radial-menu {
    position: fixed;
    width: 0;
    height: 0;
    z-index: 500;
}

.radial-item {
    position: absolute;
    width: 50px;
    height: 50px;
    background: white;
    border: 2px solid var(--node-selected);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    margin-left: -25px;
    margin-top: -25px;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-size: 24px;
    user-select: none;
}

.radial-item:active {
    background: var(--node-selected);
    color: white;
}

@media (max-width: 600px) {
    #details-pane {
        width: 100vw;
    }
    
    .actions-grid {
        grid-template-columns: 1fr;
    }

    button {
        padding: 12px 20px;
    }

    .ui-overlay {
        padding: 15px; /* Larger padding for mobile */
        bottom: 10px;
        right: 10px;
    }
}
