:root {
    --primary: #5777d8;
    --primary-hover: #2f4fc9;
    --accent: #5777d8;
    --bg: #f6f9ff;
    --glass: rgba(255, 255, 255, 0.85);
    --sidebar-bg: rgba(255, 255, 255, 0.9);
    --text: #1f2933;
    --text-light: #52606d;
    --danger: #ef4444;
    --success: #10b981;
    --border: rgba(87, 119, 216, 0.15);
    --shadow: 0 10px 15px -3px rgba(87, 119, 216, 0.1), 0 4px 6px -2px rgba(87, 119, 216, 0.05);
    --edit-mode-bg: #eff6ff;
    --edit-mode-accent: #5777d8;
    --navbar-height: 88px;
}

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

body.genogram-page {
    background-color: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.genogram-page .app-container {
    display: flex;
    flex: 1;
    height: calc(100vh - 88px);
    overflow: hidden;
}

.glass-panel {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.sidebar {
    width: 320px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s;
    overflow-y: auto;
}

.sidebar.hidden {
    transform: translateX(-100%);
}

/* Edit mode styling */
.sidebar.edit-mode {
    background: rgba(219, 234, 254, 0.85);
    border-right-color: var(--edit-mode-accent);
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 24px;
    letter-spacing: -0.025em;
    transition: color 0.3s;
}

h1.edit-mode-title {
    color: var(--edit-mode-accent);
}

.sidebar-section h3 {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
    opacity: 0.7;
}

.sidebar-section {
    margin-bottom: 32px;
}

.genogram-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.genogram-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-radius: 12px;
    background: white;
    border: 1px solid var(--border);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.genogram-item:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.genogram-item.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.genogram-item.active .delete-proj {
    color: white !important;
}

.delete-proj {
    transition: all 0.2s ease;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 1.2rem;
    line-height: 1;
}

.delete-proj:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger) !important;
}

.genogram-item.active .delete-proj:hover {
    background: rgba(255, 255, 255, 0.2);
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.btn {
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

.primary-btn {
    background: var(--primary) !important;
    color: white !important;
    border: none !important;
}

.primary-btn:hover {
    background: var(--primary-hover) !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.danger-text { color: var(--danger) !important; }
.helper-text { font-size: 0.75rem; color: var(--text-light); }

/* Canvas Area */
.canvas-area {
    flex: 1;
    position: relative;
    background: white;
    cursor: default;
    transition: background 0.3s;
}

.canvas-area.pan-mode { 
    cursor: move; /* More visible than grab in many environments */
    cursor: -webkit-grab; 
    cursor: grab; 
}
.canvas-area.pan-mode:active { 
    cursor: grabbing; 
}
.canvas-area.eraser-mode { cursor: crosshair; }

.canvas-area.edit-mode {
    background-color: #eff6ff;
}

/* cursor handled via mode classes above */

canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* Floating UI */
.toolbar-container {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    z-index: 50;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    flex-wrap: wrap;
    gap: 8px;
}

.title-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    min-width: 200px;
    pointer-events: none;
}

.top-bar > * { pointer-events: auto; }

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.top-bar-center {
    flex: 1;
    display: flex;
    justify-content: center;
    pointer-events: none;
    margin: 0 16px;
    min-width: 0;
}

.genogram-title-input {
    background: var(--glass);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    padding: 6px 20px;
    border-radius: 99px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    outline: none;
    text-align: center;
    width: 100%;
    max-width: 260px;
    text-overflow: ellipsis;
    box-shadow: var(--shadow);
    pointer-events: auto;
    transition: all 0.2s;
}

.genogram-title-input:focus {
    background: white;
    max-width: 340px;
    border-color: var(--primary);
}

.divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 8px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--glass);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}

.icon-btn:hover { background: white; transform: scale(1.1); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.icon-btn.active, .icon-btn.tool-active {
    background: white !important;
    color: #000000 !important;
    border: 2px solid #000000 !important;
    transform: scale(1.05);
    box-shadow: 0 0 0 3px rgba(87, 119, 216, 0.2);
}

.icon-btn svg {
    pointer-events: none;
}

.danger-text { color: var(--danger) !important; }

.icon-btn-sm {
    width: 30px;
    height: 30px;
    font-size: 1rem;
}

.file-menu-btn {
    width: auto;
    padding: 0 12px;
    border-radius: 18px;
}

/* Mouse Tool Selector */
.tool-selector {
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--glass);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2px;
    box-shadow: var(--shadow);
}

.tool-selector .icon-btn {
    width: 30px;
    height: 30px;
    box-shadow: none;
    border: 1px solid transparent;
}

.tool-selector .icon-btn.tool-active {
    background: white;
    color: black !important;
    border: 1px solid black;
}

.tool-selector .icon-btn svg {
    stroke: black;
    fill: none;
    transition: all 0.2s;
}

#panToolBtn.tool-active svg {
    stroke: black !important;
    fill: none !important;
}

#selectToolBtn.tool-active svg {
    fill: black !important;
    stroke: none !important;
}

#selectToolBtn svg {
    fill: black;
    stroke: none;
}

/* Removed dark inversion to ensure consistent tool selection appearance */

/* Zoom Controls */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--glass);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 3px;
    box-shadow: var(--shadow);
}

.zoom-label-text {
    padding: 4px 10px;
    border: none;
    background: transparent;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text);
    min-width: 42px;
    text-align: center;
}

.zoom-fit-btn {
    padding: 4px 12px;
    border: none;
    background: transparent;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    border-radius: 14px;
    transition: background 0.2s;
    letter-spacing: 0.03em;
}

.zoom-fit-btn:hover {
    background: rgba(37, 99, 235, 0.1);
}

/* Dropdowns */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 180px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px;
    box-shadow: var(--shadow);
    z-index: 200;
    animation: fadeIn 0.15s ease-out;
}

.dropdown-menu-up {
    top: auto;
    bottom: calc(100% + 6px);
}

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

.dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 14px;
    border: none;
    background: transparent;
    text-align: left;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s;
}

.dropdown-item:hover {
    background: #f1f5f9;
}

.dropdown-item.active {
    background: #eff6ff;
    color: var(--primary);
    font-weight: 600;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 8px;
}

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

/* Analytical toolbar */
.analytical-toolbar {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--glass);
    backdrop-filter: blur(12px);
    padding: 6px;
    border-radius: 12px;
    display: flex;
    gap: 4px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    z-index: 50;
}

.tool-btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.tool-btn.active {
    background: var(--primary);
    color: white;
}

.tool-btn:hover:not(.active) {
    background: rgba(0, 0, 0, 0.05);
}

/* Floating Menu (Contextual) */
.floating-menu {
    position: absolute;
    background: var(--glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    padding: 8px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    z-index: 60;
    min-width: 140px;
}

.action-btn {
    padding: 8px 12px;
    border-radius: 6px;
    border: none;
    background: transparent;
    text-align: left;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: background 0.2s;
}

.action-btn:hover { background: rgba(0, 0, 0, 0.05); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-light); margin-bottom: 6px; }
input[type="text"], input[type="number"], select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: white;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s;
}

input:focus, select:focus { border-color: var(--primary); }

.form-row {
    display: flex;
    gap: 8px;
}

.form-group.half {
    flex: 1;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
}

.checkbox-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    font-weight: 400;
    cursor: pointer;
}

/* Emotional Gallery */
.emotional-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.emo-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.emo-item:hover { background: #f8fafc; }
.emo-item.selected { background: #eff6ff; border-color: var(--primary); }
.emo-item span { font-size: 0.625rem; font-weight: 500; color: var(--text-light); }

.emo-svg {
    display: block;
}

/* Household items */
.household-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-radius: 8px;
    margin-bottom: 4px;
    background: white;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.household-item.active {
    background: var(--edit-mode-bg);
    border-color: var(--edit-mode-accent);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.household-item span {
    font-size: 0.8125rem;
    font-weight: 500;
}

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

.h-actions button {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: white;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text);
}

.h-actions button:hover {
    background: #f1f5f9;
    transform: translateY(-1px);
}

.h-actions .finish-btn {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    animation: pulse 2s infinite;
}

.h-actions .finish-btn:hover {
    background: var(--primary-hover);
}

/* Inline Popup */
.inline-popup {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(4px);
    z-index: 500;
}

.inline-popup-content {
    padding: 24px;
    border-radius: 16px;
    max-width: 360px;
    width: 90%;
    text-align: center;
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    max-width: 500px;
    width: 90%;
    padding: 32px;
    border-radius: 24px;
}

.hidden { display: none !important; }

/* Toast */
#toastContainer {
    position: fixed;
    bottom: 32px;
    right: 32px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 2000;
}

.toast {
    background: rgba(30, 41, 59, 0.95);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@keyframes pulse { 
    0%, 100% { opacity: 1; transform: scale(1); } 
    50% { opacity: 0.5; transform: scale(0.9); } 
}

.pulse {
    display: inline-block;
    margin-right: 4px;
    animation: pulse 1.5s infinite ease-in-out;
}

/* Copyright */
.copyright-notice {
    font-size: 0.625rem;
    color: var(--text-light);
    opacity: 0.5;
}

.divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 2px;
}

.divider-horizontal {
    height: 1px;
    background: var(--border);
    margin: 2px 0;
}

.scrollable-form {
    max-height: calc(100vh - 340px);
    overflow-y: auto;
    padding-right: 4px;
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.form-actions .btn {
    flex: 1;
}

.field-row {
    margin-bottom: 8px;
}

.small-btn {
    padding: 6px 12px;
    font-size: 0.8125rem;
}
.dropdown-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(1);
}

.mobile-only {
    display: none !important;
}

@media (max-width: 1200px) {
    .mobile-only {
        display: flex !important;
    }
    .sidebar {
        transform: translateX(-100%);
        position: absolute;
        z-index: 1000;
        transition: transform 0.3s ease;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-open .toolbar-container {
        left: 336px; /* 320px sidebar + 16px margin */
        right: 16px;
    }
}

/* Floating Menu Submenus */
.menu-item-with-submenu {
    position: relative;
    width: 100%;
}

.menu-item-with-submenu .submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    z-index: 210;
    min-width: 155px;
    flex-direction: column;
    gap: 4px;
}

.menu-item-with-submenu:hover .submenu {
    display: flex;
}

/* Print Disabling Style */
@media print {
    body {
        display: none !important;
    }
    html::after {
        content: "Printing is disabled for security and layout consistency. Please use the Export menu at the top of the Genogram Builder to export as PNG, PDF, or SVG.";
        font-family: 'Poppins', sans-serif;
        font-size: 16px;
        color: #1e293b;
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100vh;
        text-align: center;
        padding: 40px;
    }
}


/* ============================================================
   Linking Prompt Banner
   ============================================================ */
.linking-prompt {
    position: absolute;
    top: 76px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(87, 119, 216, 0.95);
    color: white;
    padding: 10px 20px;
    border-radius: 99px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 25px rgba(87, 119, 216, 0.25);
    z-index: 1000;
    pointer-events: auto;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: fadeIn 0.2s ease-out;
}

.linking-icon {
    font-size: 1.1rem;
    animation: pulse 1.5s infinite;
}

.cancel-linking-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.cancel-linking-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}


/* ============================================================
   Floating Person Editor (appears on canvas near selected node)
   ============================================================ */
/* Hover Menu Styles */
.person-hover-menu {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 10px 25px -5px rgba(87, 119, 216, 0.25);
    z-index: 300;
    pointer-events: auto;
    animation: peSlideIn 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hover-menu-btn {
    padding: 8px 12px;
    border: none;
    background: transparent;
    text-align: left;
    font-family: 'Poppins', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.hover-menu-btn:hover {
    background: var(--primary);
    color: white !important;
}

.person-editor {
    position: absolute;
    width: 320px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 20px 40px -8px rgba(87, 119, 216, 0.18), 0 8px 16px -4px rgba(0,0,0,0.08);
    z-index: 200;
    animation: peSlideIn 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: all;
    overflow: hidden;
}

@keyframes peSlideIn {
    from { opacity: 0; transform: scale(0.92) translateY(6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.person-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 10px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(87,119,216,0.08) 0%, rgba(87,119,216,0.03) 100%);
    cursor: move;
    user-select: none;
}

.person-editor-name {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}

.person-editor-close {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-light);
    font-size: 0.9rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.person-editor-close:hover {
    background: rgba(239,68,68,0.1);
    color: var(--danger);
}

.person-editor-back {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-light);
    font-size: 1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
    margin-right: 8px;
}

.person-editor-back:hover {
    background: rgba(87,119,216,0.12);
    color: var(--primary);
}

.person-editor-body {
    padding: 14px 16px 12px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.pe-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.pe-field {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.pe-half {
    flex: 1;
    min-width: 0;
}

.pe-field label {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.pe-field input,
.pe-field select {
    padding: 7px 10px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: #f8faff;
    font-size: 0.8125rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
    width: 100%;
}

.pe-field input:focus,
.pe-field select:focus {
    border-color: var(--primary);
    background: white;
}

.pe-readonly {
    background: #f1f5f9 !important;
    color: var(--text-light) !important;
    cursor: default !important;
}

.pe-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
    margin-top: 2px;
}

.person-editor .emotional-gallery {
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    margin-top: 4px;
    margin-bottom: 6px;
}

.person-editor .emo-item {
    padding: 5px 2px;
}

.person-editor .emo-item span {
    font-size: 0.55rem;
}

.pe-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.pe-action-btn {
    flex: 1;
    padding: 8px 6px;
    border: none;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s;
    font-family: inherit;
}

.pe-save-btn {
    background: var(--primary);
    color: white;
}

.pe-save-btn:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(87,119,216,0.3);
    transform: translateY(-1px);
}

.pe-index-btn {
    background: #f0f4ff;
    color: var(--primary);
    border: 1px solid rgba(87,119,216,0.25);
}

.pe-index-btn:hover { background: #dbeafe; }

.pe-delete-btn {
    background: #fff1f1;
    color: var(--danger);
    border: 1px solid rgba(239,68,68,0.2);
}

.pe-delete-btn:hover { background: #fee2e2; }

/* Mobile Specific Responsiveness and Styling */
@media (max-width: 768px) {
    .top-bar .divider {
        display: none !important;
    }
    
    .top-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }
    
    .top-bar-left {
        flex-wrap: wrap !important;
        width: 100% !important;
        justify-content: space-between !important;
        gap: 8px !important;
    }
    
    #toggleSidebarBtn {
        order: 1 !important;
    }
    
    .title-bar {
        order: 2 !important;
        flex: 1 !important;
        display: flex !important;
        justify-content: center !important;
        min-width: 0 !important;
        margin: 0 8px !important;
    }
    
    .genogram-title-input {
        max-width: 100% !important;
        font-size: 0.85rem !important;
        padding: 6px 12px !important;
    }
    
    #fileDropdown {
        order: 3 !important;
    }
    
    /* Perfect Line Break after Row 1 in Flex container */
    .top-bar-left::after {
        content: "" !important;
        width: 100% !important;
        order: 3.5 !important;
        height: 0 !important;
        display: block !important;
    }
    
    #undoBtn {
        order: 4 !important;
        margin-left: 0 !important;
    }
    
    #redoBtn {
        order: 5 !important;
    }
    
    #toolSelector {
        order: 6 !important;
        margin-left: auto !important;
    }
    
    .zoom-controls {
        width: 100% !important;
        justify-content: center !important;
        order: 7 !important;
    }
    
    .sidebar {
        width: 280px !important;
    }
    
    .sidebar-open .toolbar-container {
        left: 16px !important;
        right: 16px !important;
    }
    
    /* Transform Person Editor floating panel into a slide-up bottom sheet */
    .person-editor {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 20px 20px 0 0 !important;
        border-bottom: none !important;
        z-index: 1100 !important;
        animation: peSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
        box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.15) !important;
    }
    
    .person-editor-header {
        cursor: default !important;
        padding: 14px 20px 10px !important;
    }
    
    .person-editor-body {
        max-height: 60vh !important;
        padding: 16px 20px 24px !important;
    }
}

@keyframes peSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.pe-family-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
    margin-bottom: 12px;
}

.pe-details-group {
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

.pe-details-group summary {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 10px 0;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    outline: none;
}

.pe-details-group summary::-webkit-details-marker {
    display: none;
}

.pe-details-group summary::after {
    content: "＋";
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: bold;
}

.pe-details-group[open] summary::after {
    content: "－";
}

.pe-family-row {
    display: flex;
    gap: 8px;
}

.pe-family-btn {
    flex: 1;
    padding: 9px 10px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text);
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.pe-family-btn:hover {
    background: #f8fafc;
    border-color: var(--primary-light);
    color: var(--primary);
}

.pe-family-btn.primary-btn {
    background: var(--primary);
    color: white;
    border: none;
}

.pe-family-btn.primary-btn:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(87,119,216,0.25);
}

.pe-family-btn.danger-btn {
    background: #fff1f1;
    color: var(--danger);
    border: 1px solid rgba(239,68,68,0.2);
}

.pe-family-btn.danger-btn:hover {
    background: #fee2e2;
}

/* ─── Guided Tour ──────────────────────────────────────────────────────────── */

#tourOverlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    pointer-events: none; /* SVG backdrop passes clicks through */
}

#tourSpotlightSVG {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#tourCard {
    position: fixed;
    z-index: 10001;
    width: 340px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(15, 25, 60, 0.28), 0 4px 16px rgba(87,119,216,0.12);
    pointer-events: all;
    animation: tourCardIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    overflow: hidden;
}

@keyframes tourCardIn {
    from { opacity: 0; transform: scale(0.92) translateY(8px); }
    to   { opacity: 1; transform: scale(1)    translateY(0);   }
}

#tourCardInner {
    padding: 24px;
}

#tourProgress {
    height: 4px;
    background: rgba(87,119,216,0.15);
    border-radius: 2px;
    margin-bottom: 16px;
    overflow: hidden;
}

#tourProgressBar {
    height: 100%;
    background: linear-gradient(90deg, #5777d8, #7b93e8);
    border-radius: 2px;
    transition: width 0.35s ease;
}

#tourStepCounter {
    font-size: 0.7rem;
    font-weight: 600;
    color: #5777d8;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

#tourTitle {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1f2933;
    margin-bottom: 10px;
    line-height: 1.3;
}

#tourText {
    font-size: 0.875rem;
    color: #52606d;
    line-height: 1.6;
    margin-bottom: 20px;
}

#tourText strong {
    color: #1f2933;
    font-weight: 600;
}

#tourActions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

#tourNavBtns {
    display: flex;
    gap: 8px;
}

.tour-btn {
    border: none;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 14px;
    transition: background 0.15s, transform 0.1s;
    font-family: inherit;
}

.tour-btn:active {
    transform: scale(0.97);
}

.tour-skip {
    background: transparent;
    color: #9ca3af;
    padding: 8px 4px;
}

.tour-skip:hover {
    color: #52606d;
}

.tour-prev {
    background: #f3f4f6;
    color: #374151;
}

.tour-prev:hover {
    background: #e5e7eb;
}

.tour-next {
    background: linear-gradient(135deg, #5777d8, #7b93e8);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(87,119,216,0.35);
}

.tour-next:hover {
    background: linear-gradient(135deg, #2f4fc9, #5777d8);
}

