/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f7fa;
    color: #333;
    min-height: 100vh;
}

/* === Landing Page === */
.landing {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.landing h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #2563eb;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: #64748b;
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

#create-form {
    display: flex;
    gap: 0.75rem;
    max-width: 480px;
    width: 100%;
}

#create-form input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

#create-form input:focus {
    border-color: #2563eb;
}

#create-form button {
    padding: 0.75rem 1.5rem;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

#create-form button:hover { background: #1d4ed8; }
#create-form button:disabled { opacity: 0.6; cursor: not-allowed; }

.hint {
    margin-top: 1.5rem;
    color: #94a3b8;
    font-size: 0.85rem;
    text-align: center;
}

.hint-link {
    color: #64748b;
    text-decoration: none;
    border-bottom: 1px dotted #94a3b8;
}

.hint-link:hover {
    color: #2563eb;
    border-color: #2563eb;
}

/* === Editor === */
.editor-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
}

.toolbar-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: #2563eb;
    text-decoration: none;
}

.toolbar-sep {
    width: 1px;
    height: 24px;
    background: #e2e8f0;
}

.toolbar button {
    padding: 0.4rem 0.75rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
}

.toolbar button:hover { background: #e2e8f0; }

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #94a3b8;
    margin-left: auto;
    transition: background 0.3s;
}

.status-indicator.connected { background: #22c55e; }
.status-indicator.disconnected { background: #ef4444; }

.editor-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

#jsmind-container {
    flex: 1;
    background: #fff;
    overflow: hidden;
    position: relative;
}

/* === Notes Panel === */
.notes-panel {
    width: 300px;
    border-left: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.notes-panel[hidden] { display: none; }

.notes-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    gap: 0.5rem;
}

.notes-header span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.notes-header-actions {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.notes-header button, .notes-upload-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: #64748b;
    line-height: 1;
    padding: 0 0.2rem;
}

.notes-upload-btn {
    font-size: 1.1rem;
    display: inline-flex;
    align-items: center;
}

.notes-upload-btn:hover { color: #2563eb; }

#notes-textarea {
    flex: 1;
    min-height: 80px;
    padding: 0.75rem;
    border: none;
    border-bottom: 1px solid #e2e8f0;
    resize: none;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.5;
    background: transparent;
    outline: none;
}

#notes-textarea.drag-over {
    background: #eff6ff;
    border-color: #2563eb;
}

.notes-preview {
    flex: 1;
    padding: 0.75rem;
    overflow-y: auto;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #475569;
}

.notes-preview:empty { display: none; }

.notes-preview img {
    max-width: 100%;
    border-radius: 4px;
    margin: 0.25rem 0;
}

.notes-preview a {
    color: #2563eb;
    word-break: break-all;
}

.notes-preview .note-file-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.5rem;
    background: #f1f5f9;
    border-radius: 4px;
    text-decoration: none;
    color: #334155;
    font-size: 0.8rem;
    margin: 0.15rem 0;
}

.notes-preview .note-file-link:hover { background: #e2e8f0; }

/* === jsMind node styles (3-tier) === */
/* Root: solid blue, white text */
jmnode.root {
    background-color: #2563eb !important;
    color: #fff !important;
    border: 2px solid #1d4ed8 !important;
    font-size: 1.25rem;
}
jmnode.root:hover {
    background-color: #1d4ed8 !important;
    color: #fff !important;
}
jmnode.root.selected {
    background-color: #1e40af !important;
    color: #fff !important;
}

/* Level 1 (children of root): white bg, blue border, dark text */
jmnode[data-depth="1"] {
    background-color: #fff !important;
    color: #1e3a5f !important;
    border: 2px solid #2563eb !important;
}
jmnode[data-depth="1"]:hover {
    background-color: #eff6ff !important;
    color: #1e3a5f !important;
}
jmnode[data-depth="1"].selected {
    background-color: #dbeafe !important;
    color: #1e3a5f !important;
    border-color: #1d4ed8 !important;
}

/* Level 2+ (grandchildren): white bg, no border, dark text */
jmnode[data-depth="2"],
jmnode[data-depth="3"],
jmnode[data-depth="4"],
jmnode[data-depth="5"] {
    background-color: #fff !important;
    color: #334155 !important;
    border: none !important;
}
jmnode[data-depth="2"]:hover,
jmnode[data-depth="3"]:hover,
jmnode[data-depth="4"]:hover,
jmnode[data-depth="5"]:hover {
    background-color: #f8fafc !important;
    color: #334155 !important;
    box-shadow: 1px 1px 4px rgba(0,0,0,0.1);
}
jmnode[data-depth="2"].selected,
jmnode[data-depth="3"].selected,
jmnode[data-depth="4"].selected,
jmnode[data-depth="5"].selected {
    background-color: #f1f5f9 !important;
    color: #334155 !important;
    box-shadow: 0 0 0 2px #93c5fd;
}

/* === Meeting mode checkboxes === */
.node-checkbox {
    width: 15px;
    height: 15px;
    margin: 0 6px 0 0;
    vertical-align: middle;
    cursor: pointer;
    accent-color: #22c55e;
}

/* Done nodes in meeting mode: dimmed with strikethrough */
jmnode[data-done="true"] {
    opacity: 0.5;
    text-decoration: line-through;
}

/* Note indicator dot on jsMind nodes */
jmnode[has-note]::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f59e0b;
}

/* === Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay[hidden] { display: none; }

.modal {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.modal h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.modal input[readonly] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
    background: #f8fafc;
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.modal-actions button {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    border: none;
    font-weight: 600;
}

.modal-actions button:first-child {
    background: #2563eb;
    color: #fff;
}

.btn-secondary {
    background: #f1f5f9;
    color: #333;
    border: 1px solid #e2e8f0 !important;
}

/* === Node Tooltip === */
.node-tooltip {
    position: fixed;
    z-index: 2500;
    max-width: 320px;
    max-height: 280px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
    line-height: 1.5;
    color: #475569;
    pointer-events: none;
    animation: tooltip-in 0.15s ease;
}

.node-tooltip[hidden] { display: none; }

.node-tooltip img {
    max-width: 100%;
    max-height: 150px;
    border-radius: 4px;
    margin: 0.25rem 0;
}

.node-tooltip a {
    color: #2563eb;
    pointer-events: auto;
}

@keyframes tooltip-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Context Menu === */
.ctx-menu {
    position: fixed;
    z-index: 3000;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 4px 0;
    min-width: 160px;
}

.ctx-menu[hidden] { display: none; }

.ctx-menu button {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    text-align: left;
    font-size: 0.9rem;
    cursor: pointer;
    color: #333;
}

.ctx-menu button:hover {
    background: #f1f5f9;
}

#ctx-delete:hover {
    background: #fef2f2;
    color: #dc2626;
}

/* === Toasts === */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 2000;
}

.toast {
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    background: #1e293b;
    color: #fff;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: toast-in 0.3s ease;
    max-width: 360px;
}

.toast.error { background: #dc2626; }
.toast.warning { background: #f59e0b; color: #1e293b; }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Mobile === */
@media (max-width: 600px) {
    .landing h1 { font-size: 2rem; }
    #create-form { flex-direction: column; }
    .toolbar { gap: 0.35rem; padding: 0.4rem 0.5rem; }
    .toolbar button { padding: 0.3rem 0.5rem; font-size: 0.8rem; }
    .toolbar-sep { display: none; }
    .notes-panel { width: 100%; position: absolute; right: 0; top: 0; bottom: 0; z-index: 50; }
}
