.logbook-page {
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.logbook {
    max-width: 900px;
    padding: 30px;
    text-align: left;
    position: relative;
    margin: auto;
}

@media (max-width: 600px) {
    .logbook {
        padding: 20px 0px;
    }
}

.logbook-entry {
    background-color: var(--container-bg);
    margin-bottom: 10px;
}

/* Override card hover effects for logbook entries */
.logbook-entry:hover {
    box-shadow: none;
    transform: none;
}

/* Session markers - subtle visual break between sessions */
.session-marker {
    margin: 0;
    padding: 0;
    position: relative;
}

/* Horizontal divider line */
.session-marker::before {
    content: '';
    display: block;
    height: 1px;
    background: darkgrey;
    margin-bottom: 0.5rem;
}

/* Hide the text content on desktop - just show the divider */
.session-marker .session-number,
.session-marker .session-date {
    display: none;
}

/* First session marker shouldn't have top margin or divider */
.logbook>.session-marker:first-child,
.logbook>h1:first-child+.session-marker {
    margin-top: 0;
}

.logbook>.session-marker:first-child::before,
.logbook>h1:first-child+.session-marker::before {
    display: none;
}

/* Fixed session indicator in the gutter */
.session-indicator {
    position: fixed;
    top: 100px;
    right: calc(50% - 450px - 180px);
    /* Center of page minus half logbook width minus gutter */
    width: 150px;
    text-align: left;
    font-size: 0.85rem;
    line-height: 1.3;
    padding: 0.25rem 0 0.25rem 0.5rem;
    border-left: 3px solid #868686;
    z-index: 50;
    opacity: 0;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.session-indicator.visible {
    opacity: 1;
}

.session-indicator .session-info {
    flex: 1;
    text-align: left;
}

.session-indicator .session-number {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.session-indicator .session-date {
    display: block;
    font-style: italic;
    color: var(--text-tertiary, #999);
    font-size: 0.75rem;
}

/* Hide on smaller screens where gutter doesn't fit */
@media (max-width: 1200px) {
    .session-indicator {
        display: none;
    }

    /* Show full inline markers on mobile */
    .session-marker {
        display: block;
        margin: 1.5rem 0 0.5rem 0;
        padding: 0.5rem;
        background: var(--bg-tertiary, #f8f8f8);
        border-left: 3px solid var(--accent-blue-dark, #124f8c);
        font-size: 0.85rem;
        line-height: 1.3;
    }

    .session-marker::before {
        display: none;
    }

    .session-marker .session-number,
    .session-marker .session-date {
        display: block;
    }

    .session-marker .session-number {
        font-weight: 600;
        color: var(--text-primary);
        margin-bottom: 0.2rem;
    }

    .session-marker .session-date {
        font-style: italic;
        color: var(--text-tertiary, #999);
        font-size: 0.75rem;
    }
}

/* Card-level edit link (per-entry) */
.logbook-entry {
    position: relative;
}

.logbook-entry .card-edit-link {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: none;
    color: var(--text-tertiary, #999);
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.2s;
    z-index: 10;
}

.logbook-entry .card-edit-link:hover {
    opacity: 1;
    color: var(--accent-blue-dark, #124f8c);
}

.logbook-entry:hover .card-edit-link {
    display: block;
}

/* Session edit link - hidden by default, shown on hover */
.session-edit-link {
    display: none;
    color: var(--accent-blue-dark, #124f8c);
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding-right: 0.5rem;
    border-right: 1px solid var(--border-color, #ccc);
    position: absolute;
    left: -30px;
    top: 0px;
}

.session-edit-link:hover {
    opacity: 1;
}

/* Show edit link on session indicator hover */
.session-indicator:hover .session-edit-link {
    display: flex;
    align-items: center;
}

/* Mobile: show edit link in session marker on hover/tap */
@media (max-width: 1200px) {
    .session-marker:hover .session-edit-link {
        display: inline;
    }
}

/* ============================================
   Lightbox for logbook images
   ============================================ */
.lightbox {
    display: none;
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    background-color: rgba(0, 0, 0, 0.8);
}

.lightbox.active {
    display: flex;
    animation: lightbox-fadeIn 0.3s;
}

.lightbox-content {
    max-width: 95%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.lightbox-caption {
    color: white;
    margin-top: 15px;
    font-size: 1.1em;
    text-align: center;
    background-color: rgba(60, 59, 59, 0.8);
    padding: 5px 15px;
    border-radius: 4px;
}

.lightbox-close {
    position: fixed;
    top: 20px;
    top: max(20px, env(safe-area-inset-top));
    right: 30px;
    right: max(30px, env(safe-area-inset-right));
    color: rgb(200, 200, 200);
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    background: none;
    border: none;
    padding: 10px;
    line-height: 1;
    z-index: 1001;
}

.lightbox-close:hover {
    color: white;
    transform: scale(1.1);
}

@keyframes lightbox-fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Make images in logbook clickable */
.logbook img {
    cursor: zoom-in;
    transition: opacity 0.2s;
    max-height: 800px;
    width: auto;
    object-fit: contain;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.logbook img:hover {
    opacity: 0.9;
}

/* Latest button */
.latest-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 0.75rem 1.25rem;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 2rem;
    cursor: pointer;
    font-size: var(--font-sm);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 100;
    transition: opacity 0.2s, transform 0.2s;
}

.latest-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.latest-btn.hidden {
    opacity: 0;
    pointer-events: none;
}

/* TOC Sidebar */
.logbook-toc {
    position: fixed;
    top: 100px;
    left: calc(50% - 450px - 200px);
    left: 50px;
    width: 180px;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    z-index: 50;
    font-size: var(--font-sm);
    text-align: right;
}

.toc-header {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: var(--font-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.logbook-toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.logbook-toc li {
    margin-bottom: 0.25rem;
}

.logbook-toc a {
    color: var(--text-secondary);
    text-decoration: none;
    display: block;
    padding: 0.25rem 0;
    border-right: 2px solid transparent;
    padding-right: 0.5rem;
    transition: all 0.15s;
}

.logbook-toc a:hover {
    color: var(--text-primary);
}

.logbook-toc a.active {
    color: var(--text-primary);
    border-right-color: var(--accent-color);
    font-weight: 500;
}

/* Hide TOC on smaller screens */
@media (max-width: 1400px) {
    .logbook-toc {
        display: none;
    }
}