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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        sans-serif;
    line-height: 1.6;
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
    color: #222;
}

header {
    margin-bottom: 2rem;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

header .links {
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

header .links a {
    color: #3b9b8f;
    margin-right: 1rem;
    text-decoration: underline;
    text-underline-offset: 2px;
}

header .links a:hover {
    color: #2d7a70;
}

.toggle-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 50px;
    padding: 4px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.toggle-option {
    background: transparent;
    border: none;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 50px;
    transition: all 0.3s ease;
    font-weight: 500;
    color: #666;
    white-space: nowrap;
}

.toggle-option.active {
    background: #3b9b8f;
    color: #fff;
}

.toggle-option:hover:not(.active) {
    color: #222;
}

/* Preface container with inline sort toggle */
.preface-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    margin-bottom: 2rem;
}

.preface {
    flex: 1;
    margin: 0;
}

.sort-buttons {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.sort-option {
    background: transparent;
    border: 1px solid #ddd;
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-weight: 400;
    color: #666;
    white-space: nowrap;
}

.sort-option.active {
    background: #3b9b8f;
    color: #fff;
    border-color: #3b9b8f;
}

.sort-option:hover:not(.active) {
    border-color: #3b9b8f;
    color: #3b9b8f;
}

/* Mobile responsive for sort toggle */
@media (max-width: 768px) {
    .preface-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .sort-buttons {
        align-self: flex-start;
    }
}

.entry {
    margin-bottom: 2.5rem;
    position: relative;
}

.entry h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.entry .context {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.entry .formal,
.entry .personal {
    margin: 0.5rem 0;
}

.entry .formal ul {
    margin-left: 1.25rem;
}

.entry .formal li {
    margin-bottom: 0.25rem;
}

.hidden {
    display: none;
}

/* Interleaved media styling for personal mode */
.personal .inline-media {
    margin: 1rem 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.personal .inline-media img,
.personal .inline-media video {
    max-width: 100%;
    max-height: 280px;
    border: 1px solid #eee;
    border-radius: 4px;
}

.personal .inline-media.single img,
.personal .inline-media.single video {
    max-width: 100%;
    max-height: 320px;
}

/* Legacy media block (for formal mode) */
.media {
    margin: 1rem 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.media img,
.media video {
    max-width: 100%;
    max-height: 300px;
    border: 1px solid #eee;
}

/* Condensed media for formal/TL;DR mode */
.formal-media {
    margin: 0.75rem 0 0 0;
}

.formal-media img,
.formal-media video {
    max-width: 100%;
    max-height: 180px;
    border: 1px solid #eee;
    border-radius: 4px;
}

/* Entry links styling - obviously clickable */
.entry-links {
    font-size: 0.85rem;
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.entry-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: #3b9b8f;
    padding: 0.35rem 0.75rem;
    border: 1px solid #3b9b8f;
    border-radius: 4px;
    transition: all 0.2s ease;
    text-decoration: none;
}

.entry-links a:hover {
    background: #3b9b8f;
    color: #fff;
    text-decoration: none;
}

/* General link styling */
a {
    color: #3b9b8f;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s ease;
}

a:hover {
    color: #2d7a70;
}

/* Scrollspy navigation */
.scrollspy {
    position: fixed;
    left: 20px;
    top: 100px;
    width: 220px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding: 0;
}

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

.scrollspy li {
    margin: 0;
}

.scrollspy a {
    display: block;
    font-size: 0.8rem;
    color: #666;
    text-decoration: none;
    padding: 0.4rem 0;
    border-left: 2px solid transparent;
    padding-left: 0.75rem;
    transition: all 0.2s ease;
    line-height: 1.3;
}

.scrollspy a:hover {
    color: #3b9b8f;
    border-left-color: #ddd;
}

.scrollspy a.active {
    color: #3b9b8f;
    border-left-color: #3b9b8f;
    font-weight: 500;
}

/* Hide scrollbar but keep scrolling */
.scrollspy::-webkit-scrollbar {
    width: 4px;
}

.scrollspy::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 4px;
}

/* Mobile responsive */
@media (max-width: 1024px) {
    .scrollspy {
        display: none;
    }

    body {
        margin-left: auto;
    }
}

/* Desktop layout adjustment for scrollspy */
@media (min-width: 1025px) {
    body {
        margin-left: 280px;
    }
}
