* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Open Sans', Arial, sans-serif;
    font-size: 13px;
    overflow: hidden;
    background: #f5f5f5;
}

.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: #e0e0e0;
    color: #333;
    padding: 6px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    z-index: 100;
}

.header-left, .header-right {
    display: flex;
    gap: 6px;
    align-items: center;
}

.version-badge {
    background: #666;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    margin-left: 8px;
}

.header-btn {
    background: #f0f0f0;
    border: 1px solid #ccc;
    color: #333;
    padding: 4px 10px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 12px;
}

.header-btn:hover {
    background: #e0e0e0;
}

.format-select {
    background: #f0f0f0;
    color: #333;
    border: 1px solid #ccc;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* Sidebars */
.sidebar {
    width: 320px;
    background: #fafafa;
    overflow-y: auto;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.left-sidebar {
    border-right: 1px solid #ddd;
}

.right-sidebar {
    border-left: 1px solid #ddd;
}

.sidebar.hidden {
    display: none;
}

/* Panels */
.panel {
    margin: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    background: white;
}

.panel-header {
    background: #f5f5f5;
    padding: 6px 10px;
    font-weight: 600;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #333;
    font-size: 12px;
}

.panel-header i {
    width: 16px;
    font-size: 12px;
}

.panel-content {
    padding: 8px;
}

/* Form Elements */
.form-input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 12px;
    background: white;
    color: #333;
    margin-bottom: 6px;
}

.form-input:focus {
    outline: none;
    border-color: #888;
}

.form-select {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 12px;
    background: white;
    color: #333;
    margin-bottom: 6px;
    cursor: pointer;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger {
    width: 100%;
    padding: 5px 8px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    margin-top: 4px;
}

.btn-primary {
    background: #e0e0e0;
    color: #333;
    border: 1px solid #ccc;
}

.btn-primary:hover {
    background: #d0d0d0;
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
    border: 1px solid #ccc;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-danger {
    background: #f0e0e0;
    color: #a55;
    border: 1px solid #dcc;
}

.btn-danger:hover {
    background: #e8d0d0;
}

.relation-arrow {
    display: block;
    text-align: center;
    color: #999;
    margin: 2px 0;
    font-size: 10px;
}

/* Attributes */
.attributes-list {
    max-height: 120px;
    overflow-y: auto;
    margin-bottom: 8px;
}

.attribute-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 6px;
    background: #f5f5f5;
    border-radius: 3px;
    margin-bottom: 3px;
    font-size: 11px;
    border: 1px solid #eee;
}

.attribute-item span {
    flex: 1;
    margin-right: 6px;
}

.remove-attribute {
    background: none;
    border: none;
    color: #c66;
    cursor: pointer;
    padding: 2px;
    font-size: 11px;
}

.remove-attribute:hover {
    color: #a44;
}

.add-attribute-form {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lang-select {
    display: none;
}

.lang-select.show {
    display: block;
}

/* Info Display */
.info-row {
    margin-bottom: 6px;
    font-size: 12px;
    word-break: break-word;
}

.info-row strong {
    color: #666;
}

.info-section {
    margin-top: 8px;
}

.info-section strong {
    color: #666;
}

.attributes-display {
    margin-top: 6px;
    padding: 6px;
    background: #f5f5f5;
    border-radius: 3px;
    max-height: 120px;
    overflow-y: auto;
}

.attributes-display ul, .relations-list {
    list-style: none;
    padding-left: 0;
    margin-top: 4px;
}

.attributes-display li, .relations-list li {
    padding: 3px 0;
    font-size: 11px;
    border-bottom: 1px solid #eee;
    word-break: break-word;
}

.attributes-display li strong {
    color: #666;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 12px;
    border-bottom: 1px solid #eee;
}

.stats-row:last-child {
    border-bottom: none;
}

.stats-row span {
    color: #666;
}

.stats-row strong {
    color: #333;
}

.text-muted {
    color: #999;
    font-style: italic;
}

/* Lists */
.nodes-list-container, .relations-list-container {
    max-height: 180px;
    overflow-y: auto;
    margin-top: 6px;
}

#nodes-list, #relations-list {
    list-style: none;
    padding: 0;
}

#nodes-list li, #relations-list li {
    padding: 5px 8px;
    margin-bottom: 3px;
    background: #f5f5f5;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 11px;
    word-break: break-word;
    border: 1px solid #eee;
}

#nodes-list li:hover, #relations-list li:hover {
    background: #e8e8e8;
}

#nodes-list li.selected-node {
    background: #d0d0d0;
    color: #000;
    border-color: #aaa;
    font-weight: bold;
}

#relations-list li.selected-relation {
    background: #d0d0d0;
    color: #000;
    border-color: #aaa;
    font-weight: bold;
}

.filter-input {
    margin-bottom: 6px;
}

/* Canvas Container */
.canvas-container {
    flex: 1;
    position: relative;
    background: white;
    overflow: hidden;
}

#graph-canvas {
    width: 100%;
    height: 100%;
    cursor: grab;
    background: white;
}

#graph-canvas:active {
    cursor: grabbing;
}

/* Canvas Controls */
.canvas-controls {
    position: absolute;
    bottom: 15px;
    right: 15px;
    display: flex;
    gap: 6px;
    z-index: 10;
}

.control-btn {
    background: #f0f0f0;
    border: 1px solid #ccc;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    color: #333;
}

.control-btn:hover {
    background: #e0e0e0;
}

.control-btn.frozen {
    background: #e0d0d0;
    border-color: #c99;
}

/* Help Button */
.help-btn {
    position: fixed;
    bottom: 15px;
    left: 15px;
    background: #f0f0f0;
    color: #333;
    border: 1px solid #ccc;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.help-btn:hover {
    background: #e0e0e0;
}

/* Popup */
.popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.popup-content {
    background: white;
    width: 90%;
    max-width: 650px;
    max-height: 80vh;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
    border: 1px solid #ddd;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f5f5f5;
    color: #333;
    border-bottom: 1px solid #ddd;
}

.popup-header h2 {
    margin: 0;
    font-size: 18px;
}

.close-popup {
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    color: #999;
}

.close-popup:hover {
    color: #666;
}

.version {
    padding: 6px 20px;
    background: #fafafa;
    font-size: 11px;
    color: #888;
    border-bottom: 1px solid #eee;
}

.popup-tabs {
    display: flex;
    gap: 0;
    background: #fafafa;
    border-bottom: 1px solid #ddd;
    padding: 0 15px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 10px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #888;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: #333;
}

.tab-btn.active {
    color: #333;
    border-bottom: 2px solid #888;
}

.popup-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    color: #333;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tab-content h3 {
    margin-bottom: 12px;
    color: #333;
    font-size: 16px;
}

.tab-content ul {
    padding-left: 20px;
    margin: 12px 0;
}

.tab-content li {
    margin: 6px 0;
    line-height: 1.4;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin: 15px 0;
}

.feature-card {
    padding: 12px;
    background: #f5f5f5;
    border-radius: 6px;
    text-align: center;
    border: 1px solid #eee;
}

.feature-card i {
    font-size: 24px;
    color: #666;
    margin-bottom: 8px;
}

.feature-card h4 {
    margin-bottom: 6px;
    font-size: 13px;
}

.feature-card p {
    font-size: 11px;
    color: #888;
}

.start-btn {
    width: auto;
    padding: 8px 20px;
    margin: 12px auto 0;
    display: block;
}

.shortcuts-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
}

.shortcuts-table td {
    padding: 8px;
    border-bottom: 1px solid #eee;
}

.shortcuts-table kbd {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 2px 6px;
    font-family: monospace;
    font-size: 11px;
}

/* Log Panel */
#log {
    max-height: 120px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 11px;
}

.log-entry {
    padding: 3px 6px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.log-entry i {
    width: 14px;
    font-size: 11px;
}

.log-entry.success { color: #2c5e2c; }
.log-entry.fail { color: #c44; }
.log-entry.info { color: #4682b4; }

/* Improved Label Visibility */
.node-label {
    font-size: 12px !important;
    font-weight: 600 !important;
    fill: #2c3e50 !important;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.8) !important;
    paint-order: stroke !important;
    stroke: rgba(255, 255, 255, 0.9) !important;
    stroke-width: 2px !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
}

.node.selected .node-label {
    fill: #ff4444 !important;
    font-size: 13px !important;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.9) !important;
}

.edge-label {
    font-size: 11px !important;
    font-weight: 500 !important;
    fill: #555 !important;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.8) !important;
    paint-order: stroke !important;
    stroke: rgba(255, 255, 255, 0.9) !important;
    stroke-width: 2px !important;
}

.edge.selected .edge-label {
    fill: #ff4444 !important;
    font-size: 12px !important;
    font-weight: bold !important;
}

/* Edge styling */
.edge line {
    stroke-linecap: round;
}

/* Node styling */
.node circle {
    transition: all 0.2s ease;
    cursor: pointer;
}

.node:hover circle {
    stroke: #888 !important;
    stroke-width: 2.5px !important;
}

.node.selected circle {
    stroke: #ff4444 !important;
    stroke-width: 4px !important;
    filter: drop-shadow(0 0 3px rgba(255, 68, 68, 0.5));
}

/* Edge hover effect */
.edge {
    cursor: pointer;
}

.edge:hover line {
    stroke: #ff8888 !important;
    stroke-width: 3px !important;
}

.edge.selected line {
    stroke: #ff4444 !important;
    stroke-width: 4px !important;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f0f0f0;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* Info Panel */
.info-panel-content {
    line-height: 1.5;
    font-size: 12px;
    color: #444;
}

.info-panel-content p {
    margin-bottom: 8px;
}

.info-panel-content ul {
    margin: 5px 0 5px 20px;
    padding: 0;
}

.info-panel-content li {
    margin: 3px 0;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 280px;
    }
    
    .panel {
        margin: 6px 8px;
    }
    
    .canvas-controls {
        bottom: 10px;
        right: 10px;
    }
    
    .control-btn {
        padding: 4px 8px;
        font-size: 10px;
    }
}