/* Noto Serif Variable Font - Self-hosted */
@font-face {
    font-family: 'Noto Serif';
    font-style: normal;
    font-weight: 100 900;
    font-stretch: 62.5% 100%;
    src: url('/static/fonts/noto_serif_var.woff2') format('woff2');
    font-display: swap;
}

/* Asap Variable Font - Self-hosted */
@font-face {
    font-family: 'Asap';
    font-style: normal;
    font-weight: 100 900;
    src: url('/static/fonts/asap_var.woff2') format('woff2');
    font-display: swap;
}

/* Node type colors are set dynamically by JavaScript from graphs.py defaults.
   See state.js initNodeTypeColors() - sets --color-{type} CSS variables at runtime.
   This removes ~50 lines of hardcoded color rules and creates a single source of truth. */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Firefox scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

/* Custom scrollbars - Webkit (Chrome, Safari, Edge) */
*::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

*::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.35);
}

*::-webkit-scrollbar-corner {
    background: transparent;
}

.hidden {
    display: none !important;
}

/* SVG Icon System */
.icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
}

.icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
    stroke: currentColor;
}

/* Some icons use fill, others use stroke - reset as needed */
.icon svg.icon {
    fill: none;
}

body {
    font-family: 'Asap', sans-serif;
    background: #faf9f7;
    color: #1a1a1a;
    overflow: hidden;
    height: 100vh;
}

#toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #fff;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 20px;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border-bottom: 1px solid #e5e5e5;
    user-select: none;
}

#toolbar h1 {
    font-size: 1.2rem;
    font-weight: 600;
    font-variation-settings: "wght" 600;
    color: #1a1a1a;
}

/* Node type scroll wrapper */
.node-type-scroll-wrapper {
    position: relative;
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
}

/* Scroll buttons - floating circular */
.scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: #fff;
    color: #666;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, background 0.15s ease;
}

.scroll-btn:hover {
    background: #f0f0f0;
}

.scroll-btn-left {
    left: 0;
}

.scroll-btn-right {
    right: 0;
}

/* Show scroll buttons on wrapper hover */
.node-type-scroll-wrapper:hover .scroll-btn {
    opacity: 1;
    pointer-events: auto;
}

/* Hide buttons at scroll boundaries */
.node-type-scroll-wrapper.at-start .scroll-btn-left {
    display: none;
}

.node-type-scroll-wrapper.at-end .scroll-btn-right {
    display: none;
}

/* Node type buttons - scrollable container */
.node-type-buttons {
    display: flex;
    gap: 8px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 8px;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    scrollbar-width: none; /* Firefox - hide scrollbar */
    mask-image: linear-gradient(to right, black calc(100% - 40px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 40px), transparent 100%);
}

/* Hide scrollbar - Webkit */
.node-type-buttons::-webkit-scrollbar {
    display: none;
}

/* Remove mask when at end */
.node-type-scroll-wrapper.at-end .node-type-buttons {
    mask-image: none;
    -webkit-mask-image: none;
}

/* Center buttons when all fit (no scroll needed) */
.node-type-scroll-wrapper.at-start.at-end .node-type-buttons {
    justify-content: center;
}

.node-type-btn {
    scroll-snap-align: start;
    width: 38px;
    height: 38px;
    min-width: 38px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    transition: all 0.15s ease;
    background: none;
}

/* Node type button colors - uses --node-color set by JS */
.node-type-btn[data-type] {
    color: var(--node-color, #444);
    border-color: var(--node-color, #ccc);
}

.entity-btn-group:hover .node-type-btn[data-type] svg {
    transform: scale(1.15);
}

/* Entity button group with dropdown */
.entity-btn-group {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

.entity-parent-btn {
    position: relative;
}

/* Small dropdown indicator triangle */
.entity-btn-group:has(.entity-dropdown) .entity-parent-btn::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-top: 3px solid currentColor;
    opacity: 0.4;
}

/* Entity dropdown menu - uses fixed positioning to escape overflow:hidden */
.entity-dropdown {
    position: fixed;
    min-width: 180px;
    max-width: 240px;
    background: #fff;
    border: 2px solid #888;
    padding: 6px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 1000;
    max-height: 80vh;
    overflow-y: auto;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.entity-dropdown.hidden {
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
}

.entity-subtype-btn {
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-radius: 6px;
    width: 100%;
    padding: 10px 14px;
    text-align: left;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: background 0.2s ease;
    font-family: inherit;
}

.entity-subtype-btn .subtype-name,
.entity-subtype-btn .subtype-desc {
    transition: color 0.2s ease;
}

/* First item highlighted by default */
.entity-parent-item {
    background: var(--parent-color);
}

.entity-parent-item .subtype-name {
    color: #fff;
}

.entity-parent-item .subtype-desc {
    color: rgba(255, 255, 255, 0.75);
}

/* When hovering dropdown, remove highlight from first item unless it's hovered */
.entity-dropdown:hover .entity-parent-item:not(:hover) {
    background: transparent;
    transition: background 0.2s ease;
}

.entity-dropdown:hover .entity-parent-item:not(:hover) .subtype-name {
    color: #333;
}

.entity-dropdown:hover .entity-parent-item:not(:hover) .subtype-desc {
    color: #888;
}

/* Highlight follows hover */
.entity-subtype-btn:hover {
    background: var(--parent-color);
}

.entity-subtype-btn:hover .subtype-name {
    color: #fff;
}

.entity-subtype-btn:hover .subtype-desc {
    color: rgba(255, 255, 255, 0.75);
}

.subtype-name {
    font-weight: 600;
    font-variation-settings: "wght" 600;
    color: #333;
}

.subtype-desc {
    font-size: 0.75rem;
    color: #888;
    line-height: 1.3;
}


/* Scrollbar for dropdown */
.entity-dropdown::-webkit-scrollbar {
    width: 6px;
}

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

.entity-dropdown::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.ai-controls {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
}

.ai-controls i {
    font-size: 1rem;
}

.ai-controls select {
    padding: 8px 32px 8px 14px;
    border: none;
    border-radius: 4px;
    background: #faf9f7;
    border: 1px solid #ccc;
    color: #333;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    min-width: 180px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    transition: all 0.15s ease;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 512'%3E%3Cpath fill='%23666' d='M137.4 374.6c12.5 12.5 32.8 12.5 45.3 0l128-128c9.2-9.2 11.9-22.9 6.9-34.9s-16.6-19.8-29.6-19.8L32 192c-12.9 0-24.6 7.8-29.6 19.8s-2.2 25.7 6.9 34.9l128 128z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px;
}

.ai-controls select:focus {
    outline: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.08), 0 0 0 2px rgba(0,0,0,0.05);
}

.ai-controls select:hover {
    background-color: #f0f0f0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.08);
}

.language-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #666;
}

.language-selector i {
    font-size: 1rem;
}

.language-selector select {
    padding: 8px 32px 8px 12px;
    border-radius: 4px;
    background: #faf9f7;
    border: 1px solid #ccc;
    color: #333;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    min-width: 100px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    transition: all 0.15s ease;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 512'%3E%3Cpath fill='%23666' d='M137.4 374.6c12.5 12.5 32.8 12.5 45.3 0l128-128c9.2-9.2 11.9-22.9 6.9-34.9s-16.6-19.8-29.6-19.8L32 192c-12.9 0-24.6 7.8-29.6 19.8s-2.2 25.7 6.9 34.9l128 128z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px;
}

.language-selector select:focus {
    outline: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.08), 0 0 0 2px rgba(0,0,0,0.05);
}

.language-selector select:hover {
    background-color: #f0f0f0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.08);
}

/* Main editor area - contains canvas */
#editor-main {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
}

#canvas-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    cursor: grab;
    background: #f8f7f4;
    background-image:
        radial-gradient(circle, #d8d6d0 1px, transparent 1px);
    background-size: 24px 24px;
    user-select: none;
}

#canvas-container.grabbing {
    cursor: grabbing;
}

#connectionCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#nodeCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
}

/* Empty State */
.empty-state {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 100;
}

.empty-state.hidden {
    display: none;
}

.empty-state-content {
    text-align: center;
    max-width: 400px;
    padding: 40px;
    color: rgba(0, 0, 0, 0.45);
}

.empty-state-icon {
    display: block;
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state-icon svg {
    width: 4rem;
    height: 4rem;
}

.empty-state-text {
    font-size: 0.9rem;
    font-weight: 600;
    font-variation-settings: "wght" 400;
    line-height: 1.6;
    margin: 0;
}


/* Floating Canvas Toolbar
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */

.canvas-toolbar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: #fff;
    user-select: none;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.canvas-toolbar button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    color: #555;
    transition: all 0.15s ease;
}

.canvas-toolbar button .icon {
    width: 20px;
    height: 20px;
}

.canvas-toolbar button:hover {
    background: #ddd;
}

.canvas-toolbar button:active {
    background: #ddd;
}

.canvas-toolbar button.active {
    background: #ddd;    
}

.canvas-toolbar button.active:hover {
    background: #ccc;
}

.canvas-toolbar .zoom-level {
    min-width: 50px;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    color: #555;
    user-select: none;
}

.canvas-toolbar .toolbar-divider {
    width: 1px;
    height: 20px;
    background: #ddd;
    margin: 0 6px;
}

/* Save button states */
#saveBtn.dirty {
    color: #f59e0b;
}

#saveBtn.dirty:hover {
    background: #fef3c7;
}

#saveBtn.saving {
    animation: pulse-save 1s infinite;
    pointer-events: none;
}

@keyframes pulse-save {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}


.node {
    position: absolute;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 12px 16px;
    cursor: move;
    user-select: none;
    width: 340px;
    transition: box-shadow 0.2s, border-color 0.2s;
    z-index: 10;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    overflow: visible;
    display: flex;
    flex-direction: column;
}

.node:hover {
    border-color: #1a1a1a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.node.selected {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    outline: 2px dashed #273c75;
    outline-offset: 4px;
}

.node.loading {
    pointer-events: none;
}

.node-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    z-index: 15;
}

.node-loading-overlay .svg-loader {
    width: 48px;
    height: 48px;
    color: #666;
}

/* Node toolbar */
.node-toolbar {
    position: absolute;
    top: -36px;
    left: 50%;
    transform: translateX(-50%) scale(var(--inverse-scale, 1));
    transform-origin: center bottom;
    display: flex;
    gap: 4px;
    background: #fff;
    padding: 6px 8px;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    z-index: 20;
    user-select: none;
}

.node:hover .node-toolbar {
    opacity: 1;
    visibility: visible;
}

.node-toolbar-btn {
    width: 26px;
    height: 26px;
    border: none;
    background: #f5f5f5;
    border-radius: 3px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    color: #555;
}

.node-toolbar-btn:hover {
    background: #1a1a1a;
    color: #fff;
}

.node-toolbar-btn-danger:hover {
    background: #333;
    color: #fff;
}

.node-toolbar-btn.active {
    background: #1a1a1a;
    color: #fff;
}

/* Hidden connections badge - small dot in top-right corner */
.node-hidden-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #888;
    pointer-events: none;
}

.node-header {
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    flex-shrink: 0;
}

.node-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    color: #444;
}

.node-label {
    font-family: "Noto Serif", serif;
    font-optical-sizing: auto;
    font-style: normal;
    font-weight: 600;
    font-variation-settings: "wght" 600;
    font-size: 1.1rem;
    color: #1a1a1a;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-align: left;
    text-wrap: balance;
}

/* Node content wrapper for layout flexibility */
.node-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

/* Base node-image styles - hidden until layout determined */
.node-image {
    border-radius: 4px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;
    -webkit-user-drag: none;
    user-drag: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.node-image.node-image-loaded {
    opacity: 1;
}

.node-image img {
    display: block;
}

/* Landscape layout: image at top, full width */
.node-layout-landscape {
    display: flex;
    flex-direction: column;
}

.node-image-landscape {
    width: 100%;
    margin-bottom: 12px;
}

.node-image-landscape img {
    width: 100%;
    height: auto;
}

/* Portrait layout: image floats right, text wraps around */
.node-layout-portrait .node-content {
    display: block;
}

.node-image-portrait {
    float: right;    
    max-width: 120px;
    max-height: 160px;
    width: auto;
    min-width: 0;
    min-height: 0;
    margin: 0 0 8px 12px;
}

.node-image-portrait img {
    max-width: 120px;
    max-height: 160px;
    width: auto;
    min-width: 0;
    min-height: 0;
}

.node-layout-portrait .node-content::after {
    content: "";
    display: table;
    clear: both;
}

/* Hide images when toggled off */
.hide-images .node-image {
    display: none;
}

/* Node collapse button */
.node-collapse-btn {
    margin-left: auto;    
    border: none;
    margin-top: 4px;
    background: transparent;
    border-radius: 3px;
    cursor: pointer;
    font-size: 16px;
    color: #999;
    display: flex;
    align-self: start;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.node:hover .node-collapse-btn,
.node.collapsed .node-collapse-btn {
    opacity: 1;
}

.node-collapse-btn:hover {
    background: #f0f0f0;
    color: #333;
}

/* Collapsed node state */
.node.collapsed .node-image,
.node.collapsed .node-content {
    display: none;
}

.node-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-top: 6px;
    text-align: left;
    overflow: hidden;
    min-height: 0;
}

.node-meta {
    font-size: 0.8rem;
    font-weight: 600;
    font-variation-settings: "wght" 600;
    font-family: "Noto Serif", serif;
    line-height: 1.4;
    text-wrap: pretty;
    margin-top: 6px;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: solid 1px #ccc;
}

.node.collapsed .node-meta {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.node-meta .source-link {
    color: #888;
    text-decoration: none;
    transition: color 0.15s ease;
}

.node-meta .source-link:hover {
    color: var(--node-color, #555);
    text-decoration: underline;
}

/* Node colors - uses --node-color set by JS on each element */
.node[data-type] {
    border-left: 3px solid var(--node-color, #7a7a7a);
}

.node .node-icon {
    color: var(--node-color, #444);
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #fff;
    padding: 30px;
    border-radius: 4px;
    min-width: 320px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    position: relative;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #1a1a1a;
    font-weight: 600;
    font-variation-settings: "wght" 600;
}

.modal-content label {
    display: block;
    margin-bottom: 15px;
    color: #444;
    font-size: 0.9rem;
}

.modal-content input,
.modal-content select,
.modal-content textarea {
    width: 100%;
    padding: 10px;
    margin-top: 5px;
    background: #faf9f7;
    border: 1px solid #ccc;
    border-radius: 3px;
    color: #333;
    font-family: inherit;
    font-size: 1rem;
}

.modal-content input:focus,
.modal-content select:focus,
.modal-content textarea:focus {
    outline: none;
    border-color: #1a1a1a;
}

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

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

.modal-buttons button:first-child,
.modal-buttons .primary-btn {
    background: #1a1a1a;
    color: #fff;
}

.modal-buttons button:first-child:hover,
.modal-buttons .primary-btn:hover {
    background: #333;
}

.modal-buttons button:last-child:not(.primary-btn) {
    background: #f0f0f0;
    color: #333;
}

.modal-buttons button:last-child:not(.primary-btn):hover {
    background: #e5e5e5;
}

.modal-buttons button:disabled,
.modal-buttons button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Connection label tooltip */
.connection-label {
    position: absolute;
    background: rgba(255, 255, 255, 0.95);
    padding: 4px 8px;
    border-radius: 8px;
    font-family: "Noto Serif", serif;
    font-weight: 600;
    font-variation-settings: "wght" 600;
    font-size: 0.8rem;
    color: #1a1a1a;
    pointer-events: auto;
    transform: translate(-50%, -50%);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    text-align: center;
    max-width: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: default;
    transition: box-shadow 0.15s ease;
}

.connection-label:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.connection-label-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.connection-label-text {
    text-wrap: pretty;
}

.connection-label-dates {
    font-size: 0.65rem;
    font-weight: 400;
    font-variation-settings: "wght" 400;
    color: #666;
    font-style: italic;
}

.connection-sources {
    font-size: 0.6rem;
    color: #888;
}

.connection-sources .source-link {
    color: #888;
    text-decoration: none;
    transition: color 0.15s ease;
}

.connection-sources .source-link:hover {
    color: #333;
    text-decoration: underline;
}

/* Connection toolbar */
.connection-toolbar {
    position: absolute;
    top: -28px;
    left: 50%;
    transform: translateX(-50%) scale(var(--inverse-scale, 1));
    transform-origin: center bottom;
    display: flex;
    gap: 2px;
    background: #fff;
    padding: 3px 4px;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    z-index: 25;
    user-select: none;
}

.connection-label:hover .connection-toolbar {
    opacity: 1;
    visibility: visible;
}

.connection-toolbar-btn {
    width: 22px;
    height: 22px;
    border: none;
    background: #f5f5f5;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    color: #555;
    padding: 0;
}

.connection-toolbar-btn:hover {
    background: #1a1a1a;
    color: #fff;
}

.connection-toolbar-btn svg {
    width: 12px;
    height: 12px;
}

/* Connection modal */
.connection-modal-content {
    min-width: 360px;
}

/* User menu */
.user-menu {
    position: relative;    
    padding-left: 16px;
    border-left: 1px solid #e0e0e0;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    background: #faf9f7;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    color: #555;
    font-size: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    transition: all 0.15s ease;
}

.user-menu-btn:hover {
    background-color: #f0f0f0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.08);
    color: #333;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: white;
    border: 1px solid #e0e4e8;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    min-width: 180px;
    z-index: 300;
}

.user-dropdown.hidden {
    display: none;
}

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: #333;
    text-decoration: none;
    transition: background 0.15s;
}

.user-dropdown a:hover {
    background: #f5f7fa;
}

.user-dropdown a i {
    width: 20px;
    color: #666;
}

.user-dropdown hr {
    margin: 0;
    border: none;
    border-top: 1px solid #e0e4e8;
}

/* Graph selector button */
.graph-selector-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f5f7fa;
    border: 1px solid #d0d5dd;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    color: #333;
    font-size: 0.9rem;
    max-width: 200px;
}

.graph-selector-btn:hover {
    background: #e9ecef;
    border-color: #1a1a1a;
}

.graph-selector-btn i:first-child {
    color: #333;
}

.graph-selector-btn span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    text-align: left;
}

/* Graph selector modal */
.graph-selector-modal {
    min-width: 500px;
    max-width: 600px;
}

.graph-selector-modal h2 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.graph-actions {
    margin-bottom: 20px;
}

.graph-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e0e4e8;
    border-radius: 8px;
}

.graph-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e0e4e8;
    cursor: pointer;
    transition: background 0.15s;
}

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

.graph-list-item:hover {
    background: #f5f7fa;
}

.graph-list-item.active {
    background: #e8f4f8;
}

.graph-list-item .graph-info {
    flex: 1;
}

.graph-list-item .graph-name {
    font-weight: 500;
    font-variation-settings: "wght" 500;
    color: #333;
}

.graph-list-item .graph-meta {
    font-size: 0.8rem;
    color: #888;
    margin-top: 2px;
}

.graph-list-item .badge {
    background: #d4edda;
    color: #155724;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    margin-left: 8px;
}

.graph-list .loading {
    padding: 40px;
    text-align: center;
    color: #888;
}


.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
}

.checkbox-label input[type="checkbox"] {
    width: auto !important;
    margin: 0 !important;
}

/* ==================== FLOATING PANELS ==================== */

.floating-panel {
    position: fixed;
    background: #fff;
    border: 1px solid #d0d5dd;
    border-radius: 8px;    
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    z-index: 100;
    min-width: 250px;
    min-height: 200px;
    max-width: 90vw;
    max-height: 90vh;
}

.floating-panel.hidden {
    display: none;
}

/* Panel header with drag handle and actions */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e5e5;
    background: #fafafa;
    border-radius: 8px 8px 0 0;
    user-select: none;
}

.panel-drag-handle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: move;
    flex: 1;
}

.panel-drag-handle svg {
    color: #888;
}

.panel-drag-handle h3 {
    font-size: 0.95rem;
    font-weight: 600;
    font-variation-settings: "wght" 600;
    color: #1a1a1a;
    margin: 0;
}

.panel-actions {
    display: flex;
    gap: 4px;
}

.panel-actions .icon-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.panel-actions .icon-btn:hover {
    background: #ccc;    
}

/* Panel content area */
.panel-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Resize handle (bottom-right corner) */
.panel-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, #ccc 50%);
    border-radius: 0 0 8px 0;
}

/* Timeline panel with vertical sidebar */
.timeline-panel {
    flex-direction: row;
    right: 20px;
    top: 80px;
    width: 600px;
    height: 400px;
}

.timeline-panel .panel-content {
    flex: 1;
    border-radius: 0 8px 8px 0;
    position: relative;
}

.timeline-sidebar {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    background: #fafafa;
    border-right: 1px solid #e5e5e5;
    border-radius: 8px 0 0 8px;
    gap: 8px;
    width: 36px;
    flex-shrink: 0;
}

.timeline-sidebar .panel-drag-handle {
    cursor: move;
    padding: 4px;
    flex: 0;
}

.timeline-sidebar .panel-drag-handle i {
    color: #999;
    font-size: 0.9rem;
}

.timeline-sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.timeline-sidebar .icon-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.timeline-sidebar .icon-btn:hover {
    background: #ccc;
}

/* Graphs panel with vertical sidebar */
.graphs-panel {
    flex-direction: row;
    left: 20px;
    top: 80px;
    width: 300px;
    height: 500px;
}

.graphs-panel .panel-content {
    flex: 1;
    border-radius: 0 8px 8px 0;
}

.graphs-sidebar {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    background: #fafafa;
    border-right: 1px solid #e5e5e5;
    border-radius: 8px 0 0 8px;
    gap: 8px;
    width: 36px;
    flex-shrink: 0;
}

.graphs-sidebar .panel-drag-handle {
    cursor: move;
    padding: 4px;
    flex: 0;
}

.graphs-sidebar .panel-drag-handle i {
    color: #999;
    font-size: 0.9rem;
}

.graphs-sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.graphs-sidebar .icon-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.graphs-sidebar .icon-btn:hover {
    background: #ccc;    
}

/* Research panel with vertical sidebar */
.research-panel {
    flex-direction: row;
    left: 50%;
    top: 80px;
    width: 500px;
    height: 75vh;
    transform: translateX(-50%);
}

.research-panel .panel-content {
    flex: 1;
    border-radius: 0 8px 8px 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.research-sidebar {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    background: #fafafa;
    border-right: 1px solid #e5e5e5;
    border-radius: 8px 0 0 8px;
    gap: 8px;
    width: 36px;
    flex-shrink: 0;
}

.research-sidebar .panel-drag-handle {
    cursor: move;
    padding: 4px;
    flex: 0;
}

.research-sidebar .panel-drag-handle i {
    color: #999;
    font-size: 0.9rem;
}

.research-sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.research-sidebar .icon-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.research-sidebar .icon-btn:hover {
    background: #ccc;    
}

.research-sidebar .icon-btn.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Research panel header */
.research-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e5e5;
    background: #fafafa;
    flex-shrink: 0;
}

.research-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.research-title i {
    font-size: 1.1rem;
    color: var(--node-color, #555);
    flex-shrink: 0;
}

.research-title h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    font-variation-settings: "wght" 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.research-header .type-badge {
    font-size: 0.75rem;
    padding: 3px 8px;
    background: #f0f0f0;
    border-radius: 12px;
    color: #666;
    flex-shrink: 0;
}

/* Research content area */
.research-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.research-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #999;
    text-align: center;
}

.research-placeholder i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.research-placeholder .svg-loader {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    color: var(--node-color, #666);
}

.research-placeholder p {
    font-size: 0.95rem;
    margin: 0;
}

/* Research sections */
.research-section {
    font-family: "Noto Serif", serif;
    margin-bottom: 20px;
}

.research-section:last-child {
    margin-bottom: 0;
}

.research-section h4 {
    margin: 0 0 8px 0;
    font-size: 1rem;
    font-weight: 600;
    font-variation-settings: "wght" 600;
    color: #333;
}

.research-section p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #555;
}

/* Entity mentions in research text */
.entity-mention {
    background: rgba(100, 100, 100, 0.1);
    padding: 1px 6px;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.15s ease;
    white-space: nowrap;
    font-weight: 600;
    font-variation-settings: "wght" 600;
}

.entity-mention:hover {
    background: rgba(100, 100, 100, 0.25);
}

.entity-mention.added {
    opacity: 0.5;
    text-decoration: line-through;
    cursor: default;
}

.entity-mention.loading {
    opacity: 0.7;
    cursor: wait;
    position: relative;
    padding-right: 20px;
}

.entity-mention.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 4px;
    width: 10px;
    height: 10px;
    margin-top: -5px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: entity-mention-spin 0.6s linear infinite;
}

@keyframes entity-mention-spin {
    to { transform: rotate(360deg); }
}

/* Entity mention colors - using CSS variables from entities.json
   Colors are set dynamically by state.js initNodeTypeColors() as --color-{type}
   Using color-mix() for transparency (supported in all modern browsers) */

/* Parent types */
.entity-mention[data-type="person"] { background: color-mix(in srgb, var(--color-person, #a65d57) 20%, transparent); }
.entity-mention[data-type="person"]:hover { background: color-mix(in srgb, var(--color-person, #a65d57) 35%, transparent); }
.entity-mention[data-type="organization"] { background: color-mix(in srgb, var(--color-organization, #4a6785) 20%, transparent); }
.entity-mention[data-type="organization"]:hover { background: color-mix(in srgb, var(--color-organization, #4a6785) 35%, transparent); }
.entity-mention[data-type="place"] { background: color-mix(in srgb, var(--color-place, #5a7a62) 20%, transparent); }
.entity-mention[data-type="place"]:hover { background: color-mix(in srgb, var(--color-place, #5a7a62) 35%, transparent); }
.entity-mention[data-type="event"] { background: color-mix(in srgb, var(--color-event, #b89860) 20%, transparent); }
.entity-mention[data-type="event"]:hover { background: color-mix(in srgb, var(--color-event, #b89860) 35%, transparent); }
.entity-mention[data-type="work"] { background: color-mix(in srgb, var(--color-work, #7a6055) 20%, transparent); }
.entity-mention[data-type="work"]:hover { background: color-mix(in srgb, var(--color-work, #7a6055) 35%, transparent); }
.entity-mention[data-type="concept"] { background: color-mix(in srgb, var(--color-concept, #8a7560) 20%, transparent); }
.entity-mention[data-type="concept"]:hover { background: color-mix(in srgb, var(--color-concept, #8a7560) 35%, transparent); }
.entity-mention[data-type="period"] { background: color-mix(in srgb, var(--color-period, #8c5a6a) 20%, transparent); }
.entity-mention[data-type="period"]:hover { background: color-mix(in srgb, var(--color-period, #8c5a6a) 35%, transparent); }
.entity-mention[data-type="organism"] { background: color-mix(in srgb, var(--color-organism, #6a7a55) 20%, transparent); }
.entity-mention[data-type="organism"]:hover { background: color-mix(in srgb, var(--color-organism, #6a7a55) 35%, transparent); }
.entity-mention[data-type="language"] { background: color-mix(in srgb, var(--color-language, #7a6a85) 20%, transparent); }
.entity-mention[data-type="language"]:hover { background: color-mix(in srgb, var(--color-language, #7a6a85) 35%, transparent); }
.entity-mention[data-type="myth"] { background: color-mix(in srgb, var(--color-myth, #a07578) 20%, transparent); }
.entity-mention[data-type="myth"]:hover { background: color-mix(in srgb, var(--color-myth, #a07578) 35%, transparent); }
.entity-mention[data-type="ethnicity"] { background: color-mix(in srgb, var(--color-ethnicity, #9a6055) 20%, transparent); }
.entity-mention[data-type="ethnicity"]:hover { background: color-mix(in srgb, var(--color-ethnicity, #9a6055) 35%, transparent); }
.entity-mention[data-type="technology"] { background: color-mix(in srgb, var(--color-technology, #5a7a75) 20%, transparent); }
.entity-mention[data-type="technology"]:hover { background: color-mix(in srgb, var(--color-technology, #5a7a75) 35%, transparent); }

/* Common subtypes - inherit parent color */
.entity-mention[data-type="ruler"],
.entity-mention[data-type="political_leader"],
.entity-mention[data-type="military_leader"],
.entity-mention[data-type="religious_figure"],
.entity-mention[data-type="artist"],
.entity-mention[data-type="scholar"] { background: color-mix(in srgb, var(--color-person, #a65d57) 20%, transparent); }
.entity-mention[data-type="ruler"]:hover,
.entity-mention[data-type="political_leader"]:hover,
.entity-mention[data-type="military_leader"]:hover,
.entity-mention[data-type="religious_figure"]:hover,
.entity-mention[data-type="artist"]:hover,
.entity-mention[data-type="scholar"]:hover { background: color-mix(in srgb, var(--color-person, #a65d57) 35%, transparent); }

.entity-mention[data-type="dynasty"],
.entity-mention[data-type="state"],
.entity-mention[data-type="military_organization"],
.entity-mention[data-type="religious_organization"],
.entity-mention[data-type="enterprise"] { background: color-mix(in srgb, var(--color-organization, #4a6785) 20%, transparent); }
.entity-mention[data-type="dynasty"]:hover,
.entity-mention[data-type="state"]:hover,
.entity-mention[data-type="military_organization"]:hover,
.entity-mention[data-type="religious_organization"]:hover,
.entity-mention[data-type="enterprise"]:hover { background: color-mix(in srgb, var(--color-organization, #4a6785) 35%, transparent); }

.entity-mention[data-type="country"],
.entity-mention[data-type="settlement"],
.entity-mention[data-type="region"],
.entity-mention[data-type="structure"],
.entity-mention[data-type="natural_feature"],
.entity-mention[data-type="archaeological_site"] { background: color-mix(in srgb, var(--color-place, #5a7a62) 20%, transparent); }
.entity-mention[data-type="country"]:hover,
.entity-mention[data-type="settlement"]:hover,
.entity-mention[data-type="region"]:hover,
.entity-mention[data-type="structure"]:hover,
.entity-mention[data-type="natural_feature"]:hover,
.entity-mention[data-type="archaeological_site"]:hover { background: color-mix(in srgb, var(--color-place, #5a7a62) 35%, transparent); }

.entity-mention[data-type="conflict"],
.entity-mention[data-type="battle"],
.entity-mention[data-type="uprising"],
.entity-mention[data-type="treaty"],
.entity-mention[data-type="expedition"] { background: color-mix(in srgb, var(--color-event, #b89860) 20%, transparent); }
.entity-mention[data-type="conflict"]:hover,
.entity-mention[data-type="battle"]:hover,
.entity-mention[data-type="uprising"]:hover,
.entity-mention[data-type="treaty"]:hover,
.entity-mention[data-type="expedition"]:hover { background: color-mix(in srgb, var(--color-event, #b89860) 35%, transparent); }

.entity-mention[data-type="artifact"],
.entity-mention[data-type="artwork"],
.entity-mention[data-type="literary_work"],
.entity-mention[data-type="document"] { background: color-mix(in srgb, var(--color-work, #7a6055) 20%, transparent); }
.entity-mention[data-type="artifact"]:hover,
.entity-mention[data-type="artwork"]:hover,
.entity-mention[data-type="literary_work"]:hover,
.entity-mention[data-type="document"]:hover { background: color-mix(in srgb, var(--color-work, #7a6055) 35%, transparent); }

.entity-mention[data-type="religion"],
.entity-mention[data-type="political_system"],
.entity-mention[data-type="economic_system"],
.entity-mention[data-type="ideology"],
.entity-mention[data-type="philosophy"],
.entity-mention[data-type="theory"],
.entity-mention[data-type="custom"] { background: color-mix(in srgb, var(--color-concept, #8a7560) 20%, transparent); }
.entity-mention[data-type="religion"]:hover,
.entity-mention[data-type="political_system"]:hover,
.entity-mention[data-type="economic_system"]:hover,
.entity-mention[data-type="ideology"]:hover,
.entity-mention[data-type="philosophy"]:hover,
.entity-mention[data-type="theory"]:hover,
.entity-mention[data-type="custom"]:hover { background: color-mix(in srgb, var(--color-concept, #8a7560) 35%, transparent); }

.entity-mention[data-type="era"],
.entity-mention[data-type="dynastic_period"],
.entity-mention[data-type="reign"] { background: color-mix(in srgb, var(--color-period, #8c5a6a) 20%, transparent); }
.entity-mention[data-type="era"]:hover,
.entity-mention[data-type="dynastic_period"]:hover,
.entity-mention[data-type="reign"]:hover { background: color-mix(in srgb, var(--color-period, #8c5a6a) 35%, transparent); }

.entity-mention[data-type="animal"],
.entity-mention[data-type="plant"],
.entity-mention[data-type="microorganism"] { background: color-mix(in srgb, var(--color-organism, #6a7a55) 20%, transparent); }
.entity-mention[data-type="animal"]:hover,
.entity-mention[data-type="plant"]:hover,
.entity-mention[data-type="microorganism"]:hover { background: color-mix(in srgb, var(--color-organism, #6a7a55) 35%, transparent); }

.entity-mention[data-type="spoken_language"],
.entity-mention[data-type="language_family"],
.entity-mention[data-type="writing_system"] { background: color-mix(in srgb, var(--color-language, #7a6a85) 20%, transparent); }
.entity-mention[data-type="spoken_language"]:hover,
.entity-mention[data-type="language_family"]:hover,
.entity-mention[data-type="writing_system"]:hover { background: color-mix(in srgb, var(--color-language, #7a6a85) 35%, transparent); }

.entity-mention[data-type="deity"],
.entity-mention[data-type="mythical_creature"],
.entity-mention[data-type="legendary_figure"] { background: color-mix(in srgb, var(--color-myth, #a07578) 20%, transparent); }
.entity-mention[data-type="deity"]:hover,
.entity-mention[data-type="mythical_creature"]:hover,
.entity-mention[data-type="legendary_figure"]:hover { background: color-mix(in srgb, var(--color-myth, #a07578) 35%, transparent); }

.entity-mention[data-type="tribe"],
.entity-mention[data-type="nation"] { background: color-mix(in srgb, var(--color-ethnicity, #9a6055) 20%, transparent); }
.entity-mention[data-type="tribe"]:hover,
.entity-mention[data-type="nation"]:hover { background: color-mix(in srgb, var(--color-ethnicity, #9a6055) 35%, transparent); }

.entity-mention[data-type="vehicle"],
.entity-mention[data-type="weapon"],
.entity-mention[data-type="tool"] { background: color-mix(in srgb, var(--color-technology, #5a7a75) 20%, transparent); }
.entity-mention[data-type="vehicle"]:hover,
.entity-mention[data-type="weapon"]:hover,
.entity-mention[data-type="tool"]:hover { background: color-mix(in srgb, var(--color-technology, #5a7a75) 35%, transparent); }

/* Research suggestions section */
.research-suggestions {
    border-top: 1px solid #e5e5e5;
    padding: 12px 16px;
    background: #fafafa;
    flex-shrink: 0;
    max-height: 200px;
    overflow-y: auto;
}

.research-suggestions h4 {
    margin: 0 0 10px 0;
    font-size: 0.85rem;
    font-weight: 600;
    font-variation-settings: "wght" 600;
    color: #666;
}

.suggestion-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.suggestion-card:hover {
    border-color: #ccc;
    background: #f8f8f8;
}

.suggestion-card:last-child {
    margin-bottom: 0;
}

.suggestion-card i {
    color: var(--node-color, #555);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.suggestion-card-content {
    flex: 1;
    min-width: 0;
}

.suggestion-card-label {
    font-weight: 600;
    font-variation-settings: "wght" 600;
    font-size: 0.85rem;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-card-desc {
    font-size: 0.75rem;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-card-add {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.suggestion-card-add:hover {
    background: #1a1a1a;
    color: #fff;
}

.suggestion-card.loading {
    opacity: 0.6;
    pointer-events: none;
}

.suggestion-card.loading .suggestion-card-add {
    position: relative;
}

.suggestion-card.loading .suggestion-card-add i {
    visibility: hidden;
}

.suggestion-card.loading .suggestion-card-add::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: entity-mention-spin 0.6s linear infinite;
}

/* Tree container */
.tree-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

/* Timeline specific styles - Horizontal Gantt layout */
.timeline-scroll {
    flex: 1;
    overflow: auto;
    cursor: grab;
    user-select: none;
}

.timeline-scroll.dragging {
    cursor: grabbing;
}

.timeline-content {
    padding: 0;
    position: relative;
    min-width: 100%;
    min-height: 100%;
}

.timeline-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #999;
    text-align: center;
}

.timeline-placeholder i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.timeline-placeholder p {
    font-size: 0.95rem;
    margin: 0;
}

/* Gantt container */
.timeline-gantt {
    position: relative;
    background: #fafafa;
}

/* Grid layer (behind everything) */
.timeline-grid {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 1;
    pointer-events: none;
}

.timeline-decade-shade {
    position: absolute;
    top: 0;
    background: rgba(0, 0, 0, 0.02);
}

.timeline-grid-line {
    position: absolute;
    top: 0;
    width: 1px;
    background: rgba(0, 0, 0, 0.06);
}

/* Future column */
.timeline-future-shade {
    position: absolute;
    top: 0;
    background: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 4px,
        rgba(0, 0, 0, 0.02) 4px,
        rgba(0, 0, 0, 0.02) 8px
    );
}

.timeline-future-divider {
    width: 2px;
    background: rgba(0, 0, 0, 0.15);
}

.timeline-future-mark {
    color: #888;
    font-style: italic;
}

/* Time axis (horizontal) - sticky */
.timeline-axis {
    position: sticky;
    left: 0;
    top: 0;
    height: 28px;
    background: linear-gradient(to bottom, #fff 0%, #f5f5f5 100%);
    border-bottom: 1px solid #d0d0d0;
    z-index: 20;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.timeline-ruler {
    position: relative;
    width: 100%;
    height: 100%;
}

.timeline-year-mark {
    position: absolute;
    top: 0;
    height: 100%;
    border-left: 1px solid #ccc;
    padding: 0 6px;
    font-size: 0.8rem;
    color: #555;
    font-weight: 700;
    font-variation-settings: "wght" 700;
    display: flex;
    align-items: center;
    letter-spacing: 0.5px;
}

.timeline-year-mark span {
    display: inline-block;
    background: transparent;
}

/* Lanes container (horizontal lanes stacked vertically) */
.timeline-lanes {
    position: absolute;
    left: 0;
    top: 28px;
    width: 100%;
    z-index: 5;
}

.timeline-lane {
    position: absolute;
    left: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* Zebra striping for lanes */
.timeline-lane.lane-even {
    background: transparent;
}

.timeline-lane.lane-odd {
    background: rgba(0, 0, 0, 0.015);
}

/* Timeline items */
.timeline-item {
    position: absolute;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.timeline-item:hover {
    z-index: 15;
    transform: scale(1.02);
}

.timeline-item.highlighted {
    z-index: 16;
    transform: scale(1.03);
}

/* Point items (single dates) */
.timeline-item-point {
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
}

.timeline-item-point:hover {
    transform: translateY(-50%) scale(1.05);
}

.timeline-point-circle {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.15),
        0 4px 8px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.timeline-point-label {
    position: absolute;
    left: 50%;
    bottom: 100%;
    margin-bottom: 8px;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 0.8rem;
    color: #333;
    font-weight: 600;
    font-variation-settings: "wght" 600;
    background: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    transform: translateX(-50%) translateY(4px);
}

.timeline-point-label::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #fff;
}

.timeline-item-point:hover .timeline-point-label {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Point label inline (always visible, next to circle) */
.timeline-point-label-below {
    white-space: nowrap;
    font-size: 0.7rem;
    font-weight: 500;
    font-variation-settings: "wght" 500;
    color: #444;
    letter-spacing: 0.2px;
}

/* Range items - bar with label below */
.timeline-item-range {
    top: 4px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.timeline-range-bar {
    height: 10px;
    border-radius: 5px;
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.12),
        0 2px 6px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    background-image: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.25) 0%,
        transparent 50%,
        rgba(0, 0, 0, 0.1) 100%
    );
    background-blend-mode: overlay;
    transition: all 0.2s ease;
}

.timeline-item-range:hover .timeline-range-bar {
    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.15),
        0 4px 12px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.35);
    transform: scaleY(1.3);
}

.timeline-item-range.highlighted .timeline-range-bar {
    box-shadow:
        0 0 0 2px rgba(255, 255, 255, 0.9),
        0 4px 8px rgba(0, 0, 0, 0.2),
        0 8px 20px rgba(0, 0, 0, 0.12);
}

/* Open-ended ranges fade out in the future column */
.timeline-item-range.open-ended .timeline-range-bar {
    -webkit-mask-image: linear-gradient(
        to right,
        black 0,
        black var(--fade-start),
        transparent 100%
    );
    mask-image: linear-gradient(
        to right,
        black 0,
        black var(--fade-start),
        transparent 100%
    );
}

.timeline-range-label {
    position: absolute;
    left: 0;
    top: 8px;
    white-space: nowrap;
}

.timeline-range-title {
    font-size: 0.7rem;
    font-weight: 500;
    font-variation-settings: "wght" 500;
    color: #444;
    letter-spacing: 0.2px;
}

/* Date indicator in bottom-left corner on hover */
.timeline-date-indicator {
    position: absolute;
    bottom: 18px;
    left: 8px;
    display: none;
    align-items: center;
    z-index: 25;
    pointer-events: none;
}

.timeline-date-indicator.visible {
    display: flex;
}

.timeline-date-indicator-label {
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    font-variation-settings: "wght" 600;
    padding: 5px 10px;
    border-radius: 4px;
    white-space: nowrap;
}

/* Node highlighting from timeline */
.node.timeline-highlighted {
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.5), 0 8px 16px rgba(0, 0, 0, 0.2) !important;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.5), 0 8px 16px rgba(0, 0, 0, 0.2);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(255, 193, 7, 0.3), 0 8px 16px rgba(0, 0, 0, 0.2);
    }
}

/* Tree items - folders and graphs */
.tree-item {
    position: relative;
}

.tree-item-row {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s ease;
    gap: 8px;
    user-select: none;
}

.tree-item-row:hover {
    background: #f5f5f5;
}

.tree-item-row.active {
    background: #f0f0f0;
    border-left: 3px solid #1a1a1a;
    padding-left: 9px;
}

.tree-item-row.drag-over {
    background: #f0f0f0;
    border: 2px dashed #666;
}

/* Folder chevron */
.tree-chevron {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.tree-chevron.expanded {
    transform: rotate(90deg);
}

.tree-chevron.placeholder {
    visibility: hidden;
}

/* Tree icons */
.tree-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #555;
}

/* Tree item name */
.tree-name {
    flex: 1;
    font-size: 0.875rem;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Inline edit input */
.tree-name-input {
    flex: 1;
    font-size: 0.875rem;
    padding: 2px 6px;
    border: 1px solid #1a1a1a;
    border-radius: 3px;
    outline: none;
    background: #fff;
}

/* Tree item menu button */
.tree-menu-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    border-radius: 3px;
    cursor: pointer;
    color: #888;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.15s ease;
}

.tree-item-row:hover .tree-menu-btn {
    opacity: 1;
}

.tree-menu-btn:hover {
    background: #e5e5e5;
    color: #1a1a1a;
}

/* Nested tree children */
.tree-children {
    padding-left: 20px;
}

.tree-children.collapsed {
    display: none;
}

/* Empty state */
.tree-empty {
    padding: 20px;
    text-align: center;
    color: #888;
    font-size: 0.85rem;
}

/* Context menu */
.context-menu {
    position: fixed;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
    min-width: 160px;
    z-index: 400;
    padding: 4px 0;
    display: none;
}

.context-menu.visible {
    display: block;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 0.875rem;
    color: #333;
}

.context-menu-item:hover {
    background: #f5f5f5;
}

.context-menu-item i {
    width: 16px;
    color: #555;
}

.context-menu-item.danger {
    color: #666;
}

.context-menu-item.danger i {
    color: #666;
}

.context-menu-divider {
    height: 1px;
    background: #e5e5e5;
    margin: 6px 0;
}

/* Adjust canvas when sidebar is open */
#editor-main {
    transition: left 0.2s ease;
}

/* Loading spinner in sidebar */
.tree-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #888;
}

.tree-loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}


/* Timeline Panel
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */

#timeline-panel {
    width: 300px;
    min-width: 200px;
    max-width: 600px;
    background: #fff;
    border-left: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
    transition: width 0.15s ease;
}

#timeline-panel.collapsed {
    width: 0;
    min-width: 0;
    overflow: hidden;
    border-left: none;
}

.timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #faf9f7;
    border-bottom: 1px solid #e5e5e5;
}

.timeline-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    font-variation-settings: "wght" 600;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.timeline-header h3 i {
    color: #555;
}

.timeline-header button {
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    padding: 4px 8px;
    border-radius: 3px;
    transition: all 0.15s ease;
}

.timeline-header button:hover {
    background: #e5e5e5;
    color: #1a1a1a;
}

.timeline-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    scrollbar-width: thin;
    scrollbar-color: #c0c0c0 transparent;
}

.timeline-container::-webkit-scrollbar {
    width: 6px;
}

.timeline-container::-webkit-scrollbar-track {
    background: transparent;
}

.timeline-container::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border-radius: 3px;
}

.timeline-container::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

.timeline-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #999;
    text-align: center;
}

.timeline-placeholder i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.timeline-placeholder p {
    font-size: 0.9rem;
}


/* Timeline Resize Handle
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */

#timeline-resize-handle {
    width: 5px;
    background: #e5e5e5;
    cursor: col-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    position: relative;
    z-index: 10;
}

#timeline-resize-handle:hover,
#timeline-resize-handle.dragging {
    background: #1a1a1a;
}

.handle-grip {
    width: 2px;
    height: 30px;
    background: #aaa;
    border-radius: 1px;
    transition: background 0.15s ease;
}

#timeline-resize-handle:hover .handle-grip,
#timeline-resize-handle.dragging .handle-grip {
    background: #fff;
}

/* Hide resize handle when timeline is collapsed */
#timeline-panel.collapsed + #timeline-resize-handle,
#timeline-resize-handle:has(+ #timeline-panel.collapsed) {
    display: none;
}

/* Timeline collapsed state - show expand button */
#timeline-panel.collapsed .timeline-header,
#timeline-panel.collapsed .timeline-container {
    display: none;
}

/* Expand button when timeline is collapsed */
.timeline-expand-btn {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: #1a1a1a;
    color: #fff;
    border: none;
    padding: 12px 6px;
    border-radius: 3px 0 0 3px;
    cursor: pointer;
    z-index: 50;
    transition: all 0.15s ease;
}

.timeline-expand-btn:hover {
    background: #333;
    padding-right: 10px;
}

.timeline-expand-btn i {
    font-size: 0.9rem;
}


/* Date fields in node modal
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */

.date-fields {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e5e5e5;
}

.date-mode-label {
    margin-bottom: 12px !important;
}

.date-mode-toggle {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}

.date-mode-btn {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 3px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.date-mode-btn:hover {
    border-color: #999;
    background: #f5f5f5;
}

.date-mode-btn.active {
    background: #1a1a1a;
    color: #fff;
    border-color: #1a1a1a;
}

.date-range-fields {
    display: flex;
    gap: 12px;
}

.date-range-fields label {
    flex: 1;
}

.date-single-field.hidden,
.date-range-fields.hidden {
    display: none;
}

.date-hint {
    margin-top: 8px;
    font-size: 0.75rem;
    color: #888;
    font-style: italic;
}

.date-mode-selector {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e5e5e5;
}

.date-mode-selector .radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #555;
}

.date-mode-selector .radio-label input[type="radio"] {
    margin: 0;
    cursor: pointer;
}

#connectionSingleDate.hidden,
#connectionDateRange.hidden {
    display: none;
}

#connectionDateRange {
    display: flex;
    gap: 12px;
}

#connectionDateRange label {
    flex: 1;
}


.date-context-label {
    margin-top: 8px;
}

.date-context-label input {
    font-style: italic;
}

.node-description {
    font-size: 0.9rem;
    color: #555;
    line-height: 1.4;
    font-family: "Noto Serif", serif;
    font-optical-sizing: auto;
    font-style: normal;
}

.node-more-link {
    color: var(--node-color, #666);
    text-decoration: none;
    font-style: italic;
    opacity: 0.8;
    transition: opacity 0.15s;
}

.node-more-link:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Suggestions Modal */
.suggestions-modal-content {
    max-width: 680px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.suggestions-subtitle {
    color: #666;
    font-size: 0.95rem;
    margin-bottom: 20px;
    font-style: italic;
}

.suggestions-loading {
    text-align: center;
    padding: 60px 20px;
    color: #888;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.suggestions-loading .svg-loader {
    width: 56px;
    height: 56px;
    color: #999;
}

.suggestions-loading span {
    font-size: 0.95rem;
}

.suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 10px;
}

.suggestion-item {
    display: flex;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.15s ease;
}

.suggestion-item:hover {
    border-color: #bbb;
    background: #f5f5f5;
}

.suggestion-item.selected {
    border-color: #1a1a1a;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.suggestion-checkbox {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    min-width: 18px;
    max-width: 18px;
    margin-top: 3px;
    cursor: pointer;
    accent-color: #1a1a1a;
}

.suggestion-content {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
}

.suggestion-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.suggestion-header i {
    color: #666;
    font-size: 0.9rem;
}

.suggestion-label {
    font-weight: 600;
    font-variation-settings: "wght" 600;
    font-size: 1rem;
    color: #1a1a1a;
}

.suggestion-type {
    font-size: 0.75rem;
    color: #777;
    background: #eaeaea;
    padding: 3px 8px;
    border-radius: 2px;
    text-transform: capitalize;
    font-weight: 500;
    font-variation-settings: "wght" 500;
}

.suggestion-dates {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 6px;
    font-style: italic;
}

.suggestion-description {
    font-size: 0.9rem;
    color: #444;
    line-height: 1.5;
}

.suggestion-connection {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #e5e5e5;
    font-size: 0.85rem;
    color: #666;
}

.suggestion-connection i {
    color: #999;
    font-size: 0.8rem;
}

.suggestion-existing-badge {
    font-size: 0.7rem;
    background: #e8f5e9;
    color: #2e7d32;
    padding: 3px 8px;
    border-radius: 2px;
    margin-left: auto;
    font-weight: 600;
    font-variation-settings: "wght" 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.no-suggestions {
    text-align: center;
    padding: 40px 20px;
    color: #888;
    font-size: 0.95rem;
    font-style: italic;
}

.error-message {
    text-align: center;
    padding: 40px 20px;
    color: #d32f2f;
    font-size: 0.95rem;
}


/* Toast Notifications
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */

#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.1);
    font-size: 0.9rem;
    max-width: 400px;
    min-width: 280px;
    pointer-events: auto;
    opacity: 0;
    transform: translateX(100%);
    transition: opacity 0.3s ease, transform 0.3s ease;
    border-left: 4px solid #666;
}

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

.toast-dismissing {
    opacity: 0;
    transform: translateX(100%);
}

.toast i:first-child {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    line-height: 1.4;
    color: #333;
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #888;
    font-size: 0.85rem;
    transition: color 0.15s;
    flex-shrink: 0;
}

.toast-close:hover {
    color: #333;
}

/* Toast types */
.toast-error {
    border-left-color: #d32f2f;
}

.toast-error i:first-child {
    color: #d32f2f;
}

.toast-success {
    border-left-color: #2e7d32;
}

.toast-success i:first-child {
    color: #2e7d32;
}

.toast-warning {
    border-left-color: #ed6c02;
}

.toast-warning i:first-child {
    color: #ed6c02;
}

.toast-info {
    border-left-color: #0288d1;
}

.toast-info i:first-child {
    color: #0288d1;
}

/* Mobile responsive */
@media (max-width: 480px) {
    #toast-container {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .toast {
        max-width: none;
        min-width: auto;
    }
}
