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

:root {
    --bg-dark: #09090b;
    --bg-panel: #121214;
    --bg-input: #1c1c1f;
    --accent: #10b981;
    --accent-hover: #059669;
    --text: #e4e4e7;
    --text-dim: #71717a;
    --text-dim-2: #a1a1aa;
    --border: #27272a;
    --success: #10b981;
    --warning: #f59e0b;
    --grid-major: rgba(255, 255, 255, 0.3);
    --grid-minor: rgba(255, 255, 255, 0.08);
}

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 48px;
}

.logo {
    font-weight: 700;
    font-size: 18px;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo svg {
    width: 24px;
    height: 24px;
}

.header-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn:hover {
    background: var(--border);
}

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

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn svg {
    width: 16px;
    height: 16px;
}

/* Main Layout */
.main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Toolbar */
.toolbar {
    width: 56px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tool-btn {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    transition: all 0.2s;
    position: relative;
}

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

.tool-btn.active {
    background: var(--accent);
    color: white;
}

.tool-btn svg {
    width: 20px;
    height: 20px;
}

.tool-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50px;
    background: var(--bg-input);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 100;
}

.tool-btn:hover::after {
    opacity: 1;
}

.toolbar-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

/* Canvas Container */
.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--bg-dark);
}

#mainCanvas {
    position: absolute;
    top: 0;
    left: 0;
    cursor: crosshair;
}

.coords-display {
    position: absolute;
    bottom: 16px;
    left: 16px;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px 12px;
    border-radius: 6px;
    font-family: 'Consolas', monospace;
    font-size: 13px;
    display: flex;
    gap: 16px;
}

.coords-display span {
    color: var(--text-dim);
}

.coords-display .value {
    color: var(--accent);
    min-width: 60px;
    display: inline-block;
}

.zoom-controls {
    position: absolute;
    bottom: 16px;
    right: 16px;
    display: flex;
    gap: 4px;
}

.zoom-btn {
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    font-size: 18px;
}

.zoom-btn:hover {
    background: var(--border);
}

/* Right Panel */
.right-panel {
    width: 300px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.panel-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.panel-tab {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 13px;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.panel-tab:hover {
    color: var(--text);
}

.panel-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.panel-section {
    margin-bottom: 16px;
}

.panel-section-title {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

/* Form Controls */
.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.form-row {
    display: flex;
    gap: 8px;
}

.form-row .form-group {
    flex: 1;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
}

input[type="color"] {
    width: 100%;
    height: 36px;
    padding: 2px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
}

/* Hierarchy */
.hierarchy-item {
    display: flex;
    align-items: center;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    gap: 8px;
    margin-bottom: 2px;
}

.hierarchy-item:hover {
    background: var(--bg-input);
}

.hierarchy-item.selected {
    background: var(--accent);
}

.hierarchy-item.group {
    font-weight: 600;
}

.hierarchy-icon {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.hierarchy-name {
    flex: 1;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hierarchy-meta {
    font-size: 11px;
    color: var(--text-dim);
}

.hierarchy-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
}

.hierarchy-item:hover .hierarchy-actions {
    opacity: 1;
}

.hierarchy-action {
    width: 20px;
    height: 20px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hierarchy-action:hover {
    background: var(--border);
    color: var(--text);
}

/* Vertex List */
.vertex-list {
    max-height: 200px;
    overflow-y: auto;
    background: var(--bg-input);
    border-radius: 6px;
    font-family: 'Consolas', monospace;
    font-size: 12px;
}

.vertex-row {
    display: flex;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
}

.vertex-row:last-child {
    border-bottom: none;
}

.vertex-idx {
    width: 30px;
    color: var(--text-dim);
}

.vertex-coord {
    flex: 1;
    text-align: right;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-panel);
    border-radius: 12px;
    width: 600px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Export Preview */
.export-preview {
    background: var(--bg-input);
    border-radius: 8px;
    padding: 16px;
    font-family: 'Consolas', monospace;
    font-size: 12px;
    max-height: 300px;
    overflow: auto;
    white-space: pre;
    line-height: 1.5;
}

.export-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-dim);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 60px;
    right: 16px;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideIn 0.3s ease;
}

.toast.success {
    border-color: var(--success);
}

.toast.error {
    border-color: var(--accent);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Circle Segments Slider */
.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-container input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
}

.slider-value {
    min-width: 30px;
    text-align: center;
    font-weight: 600;
}

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

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

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

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

/* Help Text */
.help-text {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
}

/* Project Name Input */
.project-name {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 4px;
    width: 200px;
}

.project-name:hover {
    background: var(--bg-input);
}

.project-name:focus {
    background: var(--bg-input);
    outline: 1px solid var(--accent);
}

/* Developer Credit */
.dev-credit {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-dim-2);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    border: 1px solid transparent;
    z-index: 100;
}

.dev-credit:hover {
    color: var(--text);
    border-color: var(--accent);
    background: rgba(16, 185, 129, 0.15);
}

.dev-credit svg {
    width: 16px;
    height: 16px;
    opacity: 0.8;
}