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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Heading */
.heading {
    background-color: #2c3e50;
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.heading h1 {
    font-size: 2rem;
    margin: 0;
    text-align: left;
    flex-shrink: 0;
}

.welcome-text {
    margin: 0;
    font-size: 0.95rem;
    flex-shrink: 0;
    white-space: nowrap;
    text-align: right;
}

.project-name-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    justify-content: center;
}

.project-name-input {
    font-size: 1.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    outline: none;
    font-family: inherit;
    font-weight: normal;
}

.project-name-input {
    cursor: pointer;
}

.project-name-input:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.project-name-input:focus {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    cursor: text;
}

.heading p {
    margin: 0;
    font-size: 1rem;
    text-align: right;
}

.share-button {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.share-button:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.share-button:active {
    background-color: rgba(255, 255, 255, 0.4);
}

/* User Identity Panel (on blocking overlay) */
.user-identity-panel {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    min-width: 400px;
}

.user-identity-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.user-identity-content h2 {
    margin: 0;
    text-align: center;
    color: #2c3e50;
    font-size: 1.5rem;
}

.user-input-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.user-field-wrapper {
    position: relative;
    flex-shrink: 0;
}

.user-initials-input {
    width: 90px;
    padding: 0.5rem;
    border-radius: 4px;
    background-color: white;
    color: #333;
    border: 2px solid #ccc;
    text-align: center;
    outline: none;
    font-family: inherit;
    font-weight: bold;
    font-size: 1rem;
    text-transform: uppercase;
}

.user-initials-input::placeholder {
    font-weight: normal;
    text-transform: none;
}

.user-initials-input:focus {
    background-color: white;
    border-color: #4CAF50;
}

.user-initials-input.error {
    border-color: #f44336;
    background-color: #ffebee;
}

.user-initials-input.valid {
    border-color: #4CAF50;
    background-color: #e8f5e9;
}

.user-name-input {
    flex: 1;
    padding: 0.5rem;
    border-radius: 4px;
    background-color: white;
    color: #333;
    border: 2px solid #ccc;
    outline: none;
    font-family: inherit;
    font-size: 1rem;
}

.user-name-input::placeholder {
    font-weight: normal;
    text-transform: none;
}

.user-name-input:focus {
    background-color: white;
    border-color: #4CAF50;
}

.user-name-input:disabled {
    background-color: rgba(200, 200, 200, 0.5);
    color: #999;
    cursor: not-allowed;
}

/* Initials Dropdown */
.initials-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 10001;
    min-width: 250px;
    max-height: 300px;
    overflow-y: auto;
}

.initials-dropdown.show {
    display: block;
}

.dropdown-item {
    padding: 8px 12px;
    cursor: pointer;
    color: #333;
    border-bottom: 1px solid #eee;
}

.dropdown-item:hover {
    background-color: #f0f0f0;
}

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

.dropdown-item-initials {
    font-weight: bold;
    margin-right: 8px;
}

.dropdown-item-name {
    color: #666;
}

/* Menu Bar */
.menu-bar {
    background-color: #f0f0f0;
    border-bottom: 1px solid #ccc;
    display: flex;
    justify-content: space-between;
    padding: 0;
    height: 40px;
}

.menu-left {
    display: flex;
}

.menu-item {
    position: relative;
}

.menu-button {
    background: none;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 14px;
    height: 40px;
}

.menu-button:hover {
    background-color: #e0e0e0;
}

.menu-item:hover .dropdown-content {
    display: block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: white;
    min-width: 160px;
    box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.2);
    z-index: 9999;
}

.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
}

.dropdown-content a:hover {
    background-color: #f0f0f0;
}

/* Submenu */
.submenu-container {
    position: relative;
}

.has-submenu {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.submenu-content {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    background-color: white;
    min-width: 200px;
    box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    max-height: 400px;
    overflow-y: auto;
}

.submenu-container:hover .submenu-content {
    display: block;
}

.submenu-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.submenu-content a:hover {
    background-color: #f0f0f0;
}

.submenu-content .submenu-item-id {
    font-size: 0.8em;
    color: #666;
    display: block;
}

/* Zoom Controls */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0;
    padding-right: 10px;
}

.zoom-button {
    background: none;
    border: none;
    padding: 0 15px;
    cursor: pointer;
    font-size: 18px;
    height: 40px;
    color: #333;
    transition: background-color 0.2s;
}

.zoom-button:hover {
    background-color: #e0e0e0;
}

.zoom-button:active {
    background-color: #d0d0d0;
}

#center-btn {
    font-size: 20px;
}

.zoom-icon-button {
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-icon {
    width: 20px;
    height: 20px;
    display: block;
}

.scan-controls {
    display: flex;
    align-items: center;
    border-left: 1px solid #ccc;
    margin-left: 4px;
    padding-left: 4px;
}

.scan-counter {
    font-size: 11px;
    color: #666;
    min-width: 28px;
    text-align: center;
    user-select: none;
}

.scan-start-btn svg {
    display: block;
}

.viewport-coordinates {
    display: inline-block;
    padding: 4px 12px;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    color: #333;
    margin-left: 8px;
    user-select: none;
    width: 110px;
    text-align: center;
    box-sizing: border-box;
}

/* Main Container */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Viewport */
.viewport {
    flex: 1;
    min-width: 0;
    background: white;
    padding: 2rem;
    overflow: hidden;
    color: #333;
    position: relative;
}

/* Viewport Content - this is what gets scaled */
.viewport-content {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: center center;
    pointer-events: none;
}

.viewport p {
    font-size: 1.2rem;
}

.viewport.drag-over {
    background-color: #f0f0f0;
}

/* Palette */
.palette {
    width: 200px;
    flex-shrink: 0;
    background-color: #d3d3d3;
    border-left: 1px solid #999;
    padding: 1rem;
    overflow: auto;
}

.palette h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: #333;
}

.add-card-button {
    width: 100%;
    aspect-ratio: 5 / 2; /* Maintain aspect ratio when palette zooms */
    padding: 0 10px;
    margin-bottom: 1rem;
    background-color: white;
    color: black;
    border: 1px solid #999;
    border-radius: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
}

.add-card-button:hover {
    background-color: #f5f5f5;
}

.add-card-button .plus-sign {
    font-size: 2em;
    font-weight: bold;
    line-height: 1;
}

.add-card-button .cards-icon {
    height: 70%;
    width: auto;
}

/* Wormhole in Palette */
.palette-wormhole {
    width: 100%;
    aspect-ratio: 8 / 5; /* Match the galaxy image ratio */
    margin-bottom: 1rem;
    cursor: grab;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.2s, transform 0.2s;
    box-sizing: border-box;
}

.palette-wormhole:hover {
    border-color: #00CED1;
    transform: scale(1.02);
}

.palette-wormhole:active {
    cursor: grabbing;
}

.wormhole-palette-icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Card Stack in Palette */
.card-stack {
    position: relative;
    width: 100%;
    aspect-ratio: 5 / 4; /* Match viewport card ratio */
    margin-bottom: 30px;
    background: none;
}

.palette-card {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 8px;
    border: 1px solid #999;
    border-radius: 3px;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
    cursor: grab;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    text-align: center;
    user-select: none;
    overflow: visible;
    z-index: 3;
}


.palette-card:active {
    cursor: grabbing;
}

.palette-card:hover {
    box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.3);
}

/* Stack effect - cards behind the main card, offset down and to the right */
.card-stack::before,
.card-stack::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border: 1px solid #999;
    border-radius: 3px;
    background-color: inherit;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
}

.card-stack::before {
    top: 5px;
    right: -5px;
    z-index: 2;
    opacity: 0.8;
}

.card-stack::after {
    top: 10px;
    right: -10px;
    z-index: 1;
    opacity: 0.6;
}

/* Card in Viewport */
.viewport-card {
    position: absolute;
    width: 150px;
    min-height: 100px;
    padding: 0 10px 10px 10px;
    border: 1px solid #999;
    border-radius: 3px;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
    cursor: grab;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
    justify-content: flex-start;
    user-select: none;
    z-index: 1;
    overflow: hidden;
    pointer-events: auto;
}

.viewport-card:hover {
    box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.3);
}

.viewport-card * {
    cursor: grab;
}

.viewport-card.card-selected {
    outline: 3px solid #1976D2;
    outline-offset: 2px;
}

.constellation-shadow.constellation-selected {
    background-color: #BBDEFB !important;
}

.viewport-card .card-header {
    font-weight: bold;
    font-size: 14px;
    line-height: 20px;
    margin-bottom: 0;
    width: 100%;
    word-wrap: break-word;
}

.viewport-card .card-body {
    font-weight: normal;
    font-size: 12px;
    line-height: 20px;
    width: 100%;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.viewport-card .card-author {
    position: absolute;
    top: 0;
    right: 4px;
    font-size: 10px;
    font-weight: bold;
    opacity: 0.6;
    pointer-events: none;
    line-height: 20px;
}

.dragging {
    opacity: 0.6;
}

/* Custom drag image with gradient fade */
.drag-ghost {
    position: fixed;
    top: -10000px;
    left: -10000px;
    pointer-events: none;
    z-index: 10000;
    opacity: 0; /* Make ghost invisible so only the original card shows (with scaling) */
}

.drag-ghost::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0) 40%, rgba(255, 255, 255, 0.7) 100%);
    pointer-events: none;
    border-radius: 3px;
    z-index: 10;
}

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

.modal-content {
    background-color: white;
    margin: 20px auto;
    padding: 15px;
    border: 1px solid #888;
    border-radius: 5px;
    width: 300px;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.3rem;
}

.modal-content label {
    display: block;
    margin-top: 8px;
    margin-bottom: 4px;
    font-weight: bold;
    font-size: 0.9rem;
}

.modal-content input,
.modal-content select,
.modal-content textarea {
    width: 100%;
    padding: 6px;
    margin-bottom: 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-family: inherit;
}

.modal-content textarea {
    resize: vertical;
}

.share-message {
    background-color: #f5f5f5;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 15px;
    font-family: monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
    border: 1px solid #ddd;
}

.color-picker-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 15px 0;
}

#color-wheel {
    border: 1px solid #ccc;
    border-radius: 50%;
    cursor: crosshair;
}

.color-preview {
    width: 60px;
    height: 60px;
    border: 2px solid #999;
    border-radius: 5px;
    background-color: #fff9c4;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.modal-buttons button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
}

#modal-ok {
    background-color: #4CAF50;
    color: white;
}

#modal-ok:hover {
    background-color: #45a049;
}

#modal-cancel {
    background-color: #f44336;
    color: white;
}

#modal-cancel:hover {
    background-color: #da190b;
}

/* Edit Modal - override default modal styles */
#edit-modal {
    background-color: transparent; /* No dark overlay */
    pointer-events: none; /* Allow clicking through modal background */
}

#edit-modal .modal-content {
    pointer-events: all; /* Re-enable clicking on the actual content */
    margin: 0; /* Remove default centering margin */
    padding: 0; /* Remove default padding */
    border: none;
    background: transparent;
    width: auto; /* Don't constrain width */
}

/* Edit Card Visual Styling */
.edit-card-container {
    width: 150px;
    padding: 0;
    position: relative;
    background: transparent;
    display: flex;
    flex-direction: column;
}

.edit-button-row {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    width: 150px;
}

.edit-close-btn {
    background: white;
    border: 2px solid #f44336;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    color: #f44336;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    font-weight: bold;
}

.edit-close-btn:hover {
    background: #ffebee;
}

.edit-delete-btn {
    background: white;
    border: 2px solid #ff9800;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    color: #ff9800;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    font-weight: bold;
}

.edit-delete-btn:hover {
    background: #fff3e0;
}

.edit-save-btn {
    background: white;
    border: 2px solid #4CAF50;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    color: #4CAF50;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    font-weight: bold;
}

.edit-save-btn:hover {
    color: #45a049;
}

.edit-card-visual {
    position: relative;
    width: 150px;
    min-height: 120px;
    height: auto;
    max-height: 400px;
    padding: 8px 8px 4px 8px;
    border: 1px solid #999;
    border-radius: 3px;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.edit-card-header,
.edit-card-body {
    outline: none;
    font-family: inherit;
}

.edit-card-header {
    font-weight: bold;
    font-size: 11px;
    line-height: 1.2;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.edit-card-body {
    font-weight: normal;
    font-size: 9px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.edit-card-header:empty::before,
.edit-card-body:empty::before {
    content: attr(data-placeholder);
    color: #999;
    font-style: italic;
}

.edit-card-header:focus::before,
.edit-card-body:focus::before {
    content: '';
}

/* Debug Log Modal */
.log-modal-content {
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
}

.log-content {
    background-color: #1e1e1e;
    color: #d4d4d4;
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    padding: 1rem;
    border-radius: 5px;
    max-height: 60vh;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 1rem 0;
}

.log-content .log-entry {
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #333;
    padding-bottom: 0.5rem;
}

.log-content .log-timestamp {
    color: #888;
    font-size: 10px;
}

.log-content .log-level-info {
    color: #4EC9B0;
}

.log-content .log-level-warn {
    color: #DCDCAA;
}

.log-content .log-level-error {
    color: #F48771;
}
/* Identity Selection Dialog */
#identity-modal .modal-content {
    width: 450px;
    max-width: 90vw;
}

#identity-modal-title {
    margin-bottom: 5px;
}

#identity-modal-message {
    margin-bottom: 20px;
    color: #666;
    font-size: 14px;
}

.identity-options {
    margin: 20px 0;
    text-align: left;
}

.identity-option {
    margin: 0 0 12px 0;
    padding: 14px 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.15s ease;
    background-color: white;
}

.identity-option:hover {
    background-color: #f8f9fa;
    border-color: #2c3e50;
}

.identity-option input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
    margin: 0;
}

.identity-option input[type="radio"]:checked {
    accent-color: #2c3e50;
}

.identity-option label {
    cursor: pointer;
    flex: 1;
    margin: 0;
    font-size: 15px;
    font-weight: 500;
}

.identity-other-fields {
    margin: 15px 0;
    padding: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #f9f9f9;
}

.identity-other-fields label {
    display: block;
    margin-top: 10px;
    margin-bottom: 5px;
    font-weight: bold;
}

.identity-other-fields input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.identity-error {
    margin: 10px 0;
    padding: 10px;
    background-color: #ffebee;
    border: 1px solid #ef5350;
    border-radius: 4px;
    color: #c62828;
}

/* User Registration Dialog */
#register-modal .modal-content {
    width: 400px;
    max-width: 90vw;
}

#register-message {
    margin-bottom: 20px;
    color: #666;
    font-size: 14px;
}

.register-fields {
    margin: 20px 0;
    text-align: left;
}

.register-fields label {
    display: block;
    margin-top: 12px;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.register-fields input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 14px;
    transition: border-color 0.15s ease;
}

.register-fields input:focus {
    outline: none;
    border-color: #2c3e50;
    box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
}

.register-error {
    margin: 10px 0;
    padding: 10px;
    background-color: #ffebee;
    border: 1px solid #ef5350;
    border-radius: 4px;
    color: #c62828;
}

/* Read-only indicator */
.read-only-banner {
    position: fixed;
    top: 75px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #ff9800;
    color: white;
    padding: 6px 16px;
    text-align: center;
    z-index: 1000;
    font-weight: bold;
    border-radius: 4px;
    font-size: 0.85rem;
    white-space: nowrap;
}

/* Submenu section headers */
.submenu-header {
    padding: 8px 12px;
    font-weight: bold;
    font-size: 11px;
    color: #666;
    background-color: #f0f0f0;
    border-bottom: 1px solid #ddd;
    cursor: default;
    text-transform: uppercase;
}

.submenu-header:hover {
    background-color: #f0f0f0;
}

/* ============================================================
   Floating tooltip (positioned by JS in app.js setupTooltips)
   ============================================================ */
#cs-tooltip {
    position: fixed;
    z-index: 99999;
    background: rgba(30, 30, 30, 0.92);
    color: #fff;
    padding: 6px 10px;
    border-radius: 5px;
    font-size: 12px;
    line-height: 1.5;
    max-width: 260px;
    white-space: normal;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
    display: none;
}
