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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e0e0e0;
    min-height: 100vh;
    overflow: hidden;
}

.container {
    width: 100%;
    height: 100vh;
}

.hidden {
    display: none !important;
}

/* Auth Styles */
#auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.auth-box {
    background: transparent;
    border-radius: 15px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.auth-box form {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
}

.auth-box h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #fff;
    font-size: 24px;
}

.auth-box form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.auth-box form .btn {
    width: 100%;
    margin-top: 5px;
}

.auth-box form .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-box input {
    padding: 12px 15px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 14px;
}

.auth-box input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.auth-switch {
    text-align: center;
    margin-top: 15px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
}

.auth-switch a {
    color: #4fc3f7;
    text-decoration: none;
    cursor: pointer;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* Button Styles */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-add {
    padding: 8px 16px;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    color: #e0e0e0;
    border: 1px solid rgba(255,255,255,0.2);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-add:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.3);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-danger {
    background: #ff5252;
    color: #fff;
}

.btn-danger:hover {
    background: #ff1744;
}

/* App Layout */
#app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 10;
}

header h1 {
    font-size: 20px;
    color: #fff;
}

.header-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.header-controls .btn {
    padding: 10px 16px;
    font-size: 13px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.search-input {
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 13px;
    width: 400px;
    outline: none;
    transition: border-color 0.2s ease;
}

.search-input:focus {
    border-color: #667eea;
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.btn-grid:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-grid.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
}

main {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#network-container {
    width: 100%;
    height: 100%;
}

/* Sidebar */
.sidebar {
    position: fixed;
    right: 0;
    top: 0;
    width: 400px;
    height: 100vh;
    background: rgba(22, 33, 62, 0.95);
    backdrop-filter: blur(10px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.sidebar.visible {
    transform: translateX(0);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-header h2 {
    font-size: 18px;
    color: #fff;
}

.sidebar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.sidebar-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

#sidebar-body {
    line-height: 1.6;
    white-space: pre-wrap;
    color: #e0e0e0;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: #16213e;
    border-radius: 15px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-content.modal-content-large {
    max-width: 800px;
    height: auto;
    max-height: 90vh;
}

.preview-content {
    padding: 20px;
    line-height: 1.8;
    color: #e0e0e0;
    font-size: 15px;
    max-height: 70vh;
    overflow-y: auto;
}

.preview-content h1,
.preview-content h2,
.preview-content h3 {
    color: #fff;
    margin-top: 20px;
    margin-bottom: 10px;
}

.preview-content p {
    margin-bottom: 15px;
}

.preview-content img {
    max-width: 100%;
    border-radius: 8px;
    margin: 15px 0;
}

.preview-content blockquote {
    border-left: 4px solid #667eea;
    padding-left: 15px;
    margin: 15px 0;
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
}

.preview-content ul,
.preview-content ol {
    margin-left: 25px;
    margin-bottom: 15px;
}

.preview-content code {
    background: rgba(255, 255, 255, 0.08);
    color: #ff7b72;
    padding: 2px 7px;
    border-radius: 4px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.88em;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.preview-content pre {
    background: rgba(0, 0, 0, 0.45);
    padding: 16px 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 16px 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

.preview-content pre code {
    background: none;
    color: #d4d4d4;
    padding: 0;
    border: none;
    font-size: 0.95em;
    line-height: 1.6;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
    font-size: 18px;
    color: #fff;
}

form {
    padding: 20px;
    background: #16213e;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #e0e0e0;
    font-size: 13px;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    font-size: 14px;
    font-family: inherit;
    appearance: auto;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    border-color: rgba(102, 126, 234, 0.8);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
    background: rgba(40, 44, 65, 0.9);
}

/* ── Custom Zone Selector ── */
.zone-selector-wrapper {
    position: relative;
    width: 100%;
    overflow: visible;
}

.zone-selector-wrapper input[type="text"] {
    padding-right: 60px;
    border-radius: 8px;
    transition: border-radius 0.2s ease;
}

.zone-selector-wrapper.open input[type="text"] {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.zone-clear-btn {
    position: absolute;
    right: 34px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0.4;
    transition: opacity 0.15s ease;
    z-index: 2;
}

.zone-clear-btn:hover {
    opacity: 0.8;
}

.zone-clear-btn svg {
    width: 14px;
    height: 14px;
    stroke: rgba(255, 255, 255, 0.6);
    stroke-width: 2;
    stroke-linecap: round;
    fill: none;
}

.zone-selector-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    pointer-events: none;
    transition: transform 0.25s ease;
    opacity: 0.5;
    z-index: 1;
}

.zone-selector-arrow svg {
    width: 100%;
    height: 100%;
    fill: rgba(255, 255, 255, 0.6);
}

.zone-selector-wrapper.open .zone-selector-arrow {
    transform: translateY(-50%) rotate(180deg);
    opacity: 1;
}

.zone-selector-wrapper.has-value input[type="text"] {
    color: #fff;
}

.zone-selector-wrapper.has-value .zone-clear-btn {
    display: flex;
}

.zone-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
    background: rgba(20, 24, 38, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(102, 126, 234, 0.25);
    border-top: none;
    border-radius: 0 0 12px 12px;
    z-index: 1000;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(102, 126, 234, 0.05);
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.15s ease-out, transform 0.15s ease-out, visibility 0.15s;
}

.zone-dropdown:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    visibility: visible;
}

.zone-dropdown.hidden {
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    visibility: hidden;
}

.zone-dropdown-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 15px;
    color: rgba(255, 255, 255, 0.35);
    font-size: 13px;
}

.zone-dropdown-empty svg {
    opacity: 0.4;
}

.zone-create-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 14px;
    background: rgba(102, 126, 234, 0.12);
    border: 1px dashed rgba(102, 126, 234, 0.35);
    border-radius: 8px;
    margin: 8px 10px;
    cursor: pointer;
    color: rgba(102, 126, 234, 0.9);
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.zone-create-btn:hover {
    background: rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.5);
    color: #fff;
}

.zone-create-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.zone-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 36px 10px 14px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    transition: background 0.1s ease, color 0.1s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    position: relative;
}

.zone-item:last-child {
    border-bottom: none;
}

.zone-item:hover {
    background: rgba(102, 126, 234, 0.18) !important;
    color: #fff !important;
}

.zone-item.selected {
    background: rgba(102, 126, 234, 0.25);
    color: #fff;
    font-weight: 500;
}

.zone-color-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    border: 2px solid rgba(255, 255, 255, 0.15);
    transition: transform 0.15s ease;
    cursor: pointer;
}

.zone-color-dot:hover {
    transform: scale(1.25);
}

.zone-item:hover .zone-color-dot {
    transform: scale(1.15);
}

.zone-item-check {
    margin-left: auto;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.zone-item-check svg {
    width: 100%;
    height: 100%;
    fill: rgba(102, 126, 234, 0.9);
}

.zone-item.selected .zone-item-check {
    opacity: 1;
}

.zone-item-delete {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease;
    border-radius: 4px;
}

.zone-item:hover .zone-item-delete {
    opacity: 0.5;
}

.zone-item-delete:hover {
    opacity: 1 !important;
    background: rgba(239, 68, 68, 0.2);
}

.zone-item-delete svg {
    width: 14px;
    height: 14px;
    stroke: #ef4444;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.zone-item .zone-count-badge {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 500;
    flex-shrink: 0;
    margin-left: -4px !important;
}

.zone-item:hover .zone-count-badge {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.7);
}

/* Scrollbar for zone dropdown */
.zone-dropdown::-webkit-scrollbar {
    width: 5px;
}

.zone-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.zone-dropdown::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 3px;
}

.zone-dropdown::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

.form-group select {
    cursor: pointer;
}

.form-group select option {
    background: #1a1a2e;
    color: #fff;
}

.form-group input[type="color"] {
    width: 38px;
    height: 38px;
    padding: 2px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    background: transparent;
}

.form-group input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.form-group input[type="color"]::-webkit-color-swatch { border: none; border-radius: 50%; }
.form-group input[type="color"]::-moz-color-swatch { border: none; border-radius: 50%; }

.form-group textarea {
    resize: vertical;
    min-height: 150px;
}

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

/* Checkbox Styles (Custom Switch Toggle) */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    margin-bottom: 8px;
}

.checkbox-group .custom-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.checkbox-group .custom-switch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.checkbox-group .custom-switch .switch-track {
    width: 40px;
    height: 22px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 11px;
    position: relative;
    transition: background 0.25s ease;
    flex-shrink: 0;
}

.checkbox-group .custom-switch .switch-track::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: rgba(255, 255, 255, 0.55);
    border-radius: 50%;
    transition: transform 0.25s ease, background 0.25s ease;
}

.checkbox-group .custom-switch input[type="checkbox"]:checked + .switch-track {
    background: rgba(102, 126, 234, 0.65);
}

.checkbox-group .custom-switch input[type="checkbox"]:checked + .switch-track::before {
    transform: translateX(18px);
    background: #ffffff;
}

.checkbox-group .custom-switch .switch-label {
    font-size: 13px;
    color: #e0e0e0;
    margin: 0;
    cursor: pointer;
}

/* Color Picker Row */
.color-picker-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-picker-row input[type="color"] {
    width: 36px;
    height: 36px;
    padding: 2px;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    background: transparent;
    flex-shrink: 0;
}

.color-picker-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker-row input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }
.color-picker-row input[type="color"]::-moz-color-swatch { border: none; border-radius: 6px; }

.color-hex {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    font-family: 'Consolas', 'Monaco', monospace;
    letter-spacing: 0.5px;
    min-width: 65px;
}

/* Zone Color Compact */
#node-zone-color, #edit-zone-color {
    width: 36px !important;
    height: 36px !important;
    border-radius: 8px !important;
    border: 2px solid rgba(255, 255, 255, 0.15) !important;
}

.checkbox-group input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 40px;
    height: 22px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 11px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
    border: none;
    margin: 0;
}

.checkbox-group input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 18px; height: 18px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}

.checkbox-group input[type="checkbox"]:checked {
    background: rgba(102, 126, 234, 0.6);
}

.checkbox-group input[type="checkbox"]:checked::after {
    transform: translateX(18px);
    background: #fff;
}

.checkbox-group label {
    margin: 0;
    cursor: pointer;
    color: #e0e0e0;
    font-size: 13px;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    display: none;
    margin: 0;
    cursor: pointer;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '✓';
    color: #fff;
    font-size: 14px;
    font-weight: bold;
}

/* Tags Styles */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    min-height: 36px;
}

.tag-input-wrapper {
    display: flex;
    align-items: center;
}

.tag-input {
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 13px;
    width: 150px;
    outline: none;
}

.tag-input:focus {
    border-color: #667eea;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.3), rgba(102, 126, 234, 0.15));
    border: 1px solid rgba(102, 126, 234, 0.4);
    color: #e0e7ff;
    font-size: 12px;
    font-weight: 500;
    cursor: grab;
    user-select: none;
    animation: tagFadeIn 0.2s ease;
    transition: background 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.tag-chip:active {
    cursor: grabbing;
}

.tag-chip.dragging {
    opacity: 0.4;
    transform: scale(0.95);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.tag-chip.drag-over {
    border-color: rgba(102, 126, 234, 0.8);
    background: rgba(102, 126, 234, 0.25);
    transform: scale(1.05);
}

@keyframes tagFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes tagFadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.tag-chip .tag-remove {
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.tag-chip .tag-remove:hover {
    opacity: 1;
}

.btn-tag-add {
    padding: 4px 12px;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px dashed rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
}

.btn-tag-add:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* Hidden editor container */
.editor-hidden {
    display: none !important;
}

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

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Article Fullscreen View */
.article-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    background: transparent;
}

.article-iframe::-webkit-scrollbar {
    width: 8px;
}

.article-iframe::-webkit-scrollbar-track {
    background: rgba(26, 26, 46, 0.5);
}

.article-iframe::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.4);
    border-radius: 4px;
}

.article-iframe::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.7);
}

.article-iframe-preview {
    width: 100%;
    height: 380px;
    border: none;
    border-radius: 8px;
    display: block;
}

.article-iframe-preview::-webkit-scrollbar {
    width: 4px;
}

.article-iframe-preview::-webkit-scrollbar-track {
    background: transparent;
}

.article-iframe-preview::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 2px;
}

#article-title {
    display: none !important;
}

.article-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1a1a2e;
    z-index: 300;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.article-view.visible {
    opacity: 1;
    transform: translateX(0);
}

.article-view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-back {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.2);
}

.article-view-actions {
    display: flex;
    gap: 10px;
}

.article-view-content {
    flex: 1;
    padding: 0;
    overflow-y: auto;
    display: block;
    min-height: 0;
}

.article-view-content > *:not(.article-iframe) {
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    padding: 40px 60px;
}

.article-view-content > .article-iframe {
    max-width: none;
    margin: 0;
    width: 100%;
    padding: 0;
}

#article-body.article-html-mode {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
}

.article-view-content h1 {
    font-size: 32px;
    color: #fff;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    width: 100% !important;
    clear: both !important;
    display: block;
}

/* Lightbox */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox-overlay.visible {
    opacity: 1;
}

.lightbox-overlay img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 36px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 10px;
    transition: color 0.2s;
}

.lightbox-close:hover {
    color: #667eea;
}

.lightbox-caption {
    position: absolute;
    bottom: 30px;
    left: 0;
    right: 0;
    text-align: center;
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    padding: 0 20px;
}

.article-view-content h1,
.article-view-content h2,
.article-view-content h3 {
    clear: both;
    padding-top: 20px;
}

/* ── MD Upload Zone ── */
.md-file-input {
    display: none;
}

.md-upload-zone {
    position: relative;
}

.md-upload-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 32px 24px;
    background: linear-gradient(135deg, rgba(22, 33, 62, 0.95) 0%, rgba(26, 26, 46, 0.95) 100%);
    border: 2px dashed rgba(102, 126, 234, 0.35);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.md-upload-btn::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 16px;
    padding: 2px;
    background: linear-gradient(135deg, rgba(102,126,234,0.0), rgba(118,75,162,0.0));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    transition: background 0.4s ease;
    pointer-events: none;
}

.md-upload-btn:hover {
    border-color: transparent;
    background: linear-gradient(135deg, rgba(26, 33, 66, 0.98) 0%, rgba(30, 30, 55, 0.98) 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.15), 0 0 0 1px rgba(102, 126, 234, 0.2);
}

.md-upload-btn:hover::before {
    background: linear-gradient(135deg, rgba(102,126,234,0.5), rgba(118,75,162,0.5));
}

.md-upload-btn:active {
    transform: translateY(0px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.md-upload-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 18px;
    background: rgba(102, 126, 234, 0.08);
    transition: all 0.35s ease;
}

.md-upload-btn:hover .md-upload-icon {
    background: rgba(102, 126, 234, 0.14);
    transform: scale(1.05);
}

.md-upload-icon svg {
    filter: drop-shadow(0 2px 8px rgba(102, 126, 234, 0.3));
    transition: filter 0.3s ease;
}

.md-upload-btn:hover .md-upload-icon svg {
    filter: drop-shadow(0 4px 16px rgba(102, 126, 234, 0.5));
}

.md-upload-title {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.3px;
}

.md-upload-subtitle {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 400;
}

/* Drag-over state */
.md-upload-zone.drag-over .md-upload-btn {
    border-color: transparent;
    background: linear-gradient(135deg, rgba(26, 38, 78, 0.98) 0%, rgba(34, 30, 62, 0.98) 100%);
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.25), inset 0 0 40px rgba(102, 126, 234, 0.05);
}

.md-upload-zone.drag-over .md-upload-btn::before {
    background: linear-gradient(135deg, rgba(102,126,234,0.7), rgba(118,75,162,0.7));
    animation: gradient-rotate 2s linear infinite;
}

@keyframes gradient-rotate {
    0% { background: linear-gradient(0deg, rgba(102,126,234,0.6), rgba(118,75,162,0.6)); }
    25% { background: linear-gradient(90deg, rgba(102,126,234,0.6), rgba(118,75,162,0.6)); }
    50% { background: linear-gradient(180deg, rgba(102,126,234,0.6), rgba(118,75,162,0.6)); }
    75% { background: linear-gradient(270deg, rgba(102,126,234,0.6), rgba(118,75,162,0.6)); }
    100% { background: linear-gradient(360deg, rgba(102,126,234,0.6), rgba(118,75,162,0.6)); }
}

/* ── MD File Actions Bar ── */
.md-file-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(102, 126, 234, 0.08);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 10px;
    margin-top: 10px;
    animation: fadeSlideIn 0.3s ease;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.md-file-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #e0e0e0;
    font-size: 13px;
    font-weight: 500;
    min-width: 0;
    overflow: hidden;
}

.md-file-info span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.md-file-btns {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ── Article Preview Container ── */
.article-preview-container {
    margin-top: 12px;
    padding: 28px 32px;
    background: rgba(13, 17, 30, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
    max-width: 100%;
    line-height: 1.75;
    color: #e2e4e9;
    font-size: 14.5px;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    animation: fadeSlideIn 0.3s ease;
}

.article-view .article-preview-container {
    max-height: none;
    overflow-y: visible;
    overflow-x: visible;
    border: none;
    background: transparent;
    padding: 0;
    margin-top: 20px;
}

.article-preview-container::-webkit-scrollbar { width: 5px; }
.article-preview-container::-webkit-scrollbar-track { background: transparent; }
.article-preview-container::-webkit-scrollbar-thumb { background: rgba(102,126,234,0.25); border-radius: 3px; }

/* Carousel Styles */
.carousel-container {
    position: relative;
    margin: 20px 0;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
}

.carousel-slide {
    display: none;
    text-align: center;
}

.carousel-slide.active {
    display: block;
}

.carousel-slide img {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
    margin: 0 auto;
    display: block;
}

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.carousel-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.carousel-prev {
    left: 10px;
}

.carousel-next {
    right: 10px;
}

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 10px;
}

.carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: background 0.2s;
}

.carousel-dot.active {
    background: #667eea;
}

.carousel-dot:hover {
    background: rgba(255, 255, 255, 0.6);
}

.carousel-empty {
    padding: 30px;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
}

/* Minimap */
.minimap-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 220px;
    height: 165px;
    background: rgba(22, 33, 62, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    z-index: 50;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

#minimap-container canvas {
    border-radius: 12px;
    background: transparent;
}

/* Color Picker Row */
.color-picker-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-hex {
    font-size: 13px;
    color: rgba(255,255,255,0.5);
    font-family: 'Consolas', monospace;
    letter-spacing: 0.5px;
}

/* Zone Color Compact */
#node-zone-color, #edit-zone-color {
    width: 36px !important;
    height: 36px !important;
    border-radius: 8px !important;
    border: 2px solid rgba(255,255,255,0.15) !important;
}

/* Modal Content Scrollbar */
.modal-content::-webkit-scrollbar {
    width: 6px;
}
.modal-content::-webkit-scrollbar-track {
    background: transparent;
}
.modal-content::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 3px;
}
.modal-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.25);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
    }

    header {
        padding: 10px 15px;
    }

    header h1 {
        font-size: 16px;
    }

    .modal-content {
        width: 95%;
        margin: 10px;
    }

    .article-view-content {
        padding: 20px;
    }

    .article-view-content h1 {
        font-size: 24px;
    }

    .article-view-header {
        padding: 10px 15px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .minimap-container {
        width: 160px;
        height: 120px;
        bottom: 10px;
        right: 10px;
    }
}

/* Inbox Sidebar (left side) */
.inbox-sidebar {
    left: 0;
    right: auto;
    width: 350px;
    transform: translateX(-100%);
    border-left: none;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.inbox-sidebar.visible {
    transform: translateX(0);
}

.inbox-input-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.inbox-input-area textarea {
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: #e0e0e0;
    font-size: 13px;
    resize: vertical;
    outline: none;
    font-family: inherit;
}

.inbox-input-area textarea:focus {
    border-color: #667eea;
}

.inbox-input-area textarea::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.inbox-note-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
}

.inbox-note-card .note-content {
    font-size: 13px;
    color: #e0e0e0;
    margin-bottom: 10px;
    word-break: break-word;
    white-space: pre-wrap;
}

.inbox-note-card .note-date {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 8px;
}

.inbox-note-card .note-actions {
    display: flex;
    gap: 8px;
}

/* Favorites Dropdown */
.dropdown {
    position: fixed;
    top: 70px;
    right: 120px;
    background: rgba(22, 33, 62, 0.97);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 8px;
    z-index: 200;
    max-height: 400px;
    overflow-y: auto;
    min-width: 250px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.dropdown-item {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #e0e0e0;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dropdown-item:hover {
    background: rgba(102, 126, 234, 0.2);
}

.dropdown-item .fav-icon {
    font-size: 14px;
}

.dropdown-empty {
    padding: 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
}
