body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    background-color: #f4f7f9;
    margin: 0;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

nav {
    background-color: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    padding: 0.5rem 2rem;
    margin-bottom: 40px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    position: relative;
}

nav ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

nav li {
    margin: 0 15px;
}

nav a {
    text-decoration: none;
    color: #333;
    font-weight: bold;
    padding: 10px;
    border-radius: 5px;
    transition: background-color 0.2s ease-in-out;
}

nav a:hover, nav a.active {
    background-color: #eef5ff; /* A subtle hover/active color */
}

.header {
    text-align: center;
    margin-bottom: 40px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 20px;
}

h1 { font-size: 2.5rem; color: #1a1a1a; }
h2, h3, h4 { color: #1a1a1a; }

.content-container {
    max-width: 800px;
    margin: 0 auto;
    background-color: #ffffff;
    padding: 2rem 4rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}

.dialogue-entry { 
    margin-bottom: 2rem; 
    display: flex; 
    flex-direction: column; 
}

.bubble {
    padding: 15px 25px;
    border-radius: 20px;
    max-width: 85%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    overflow-wrap: break-word;
}

.user-bubble {
    background-color: #007aff;
    color: #ffffff;
    border-bottom-right-radius: 5px;
    align-self: flex-end;
}

.ai-bubble {
    background-color: #ffffff;
    color: #333;
    border-bottom-left-radius: 5px;
    align-self: start;
    border: 1px solid #e0e0e0;
}

.ai-bubble p, .user-bubble p { margin: 1em 0; }
.ai-bubble p:first-child, .user-bubble p:first-child { margin-top: 0; }
.ai-bubble p:last-child, .user-bubble p:last-child { margin-bottom: 0; }
.ai-bubble ul, .ai-bubble ol { padding-left: 20px; }

.label { 
    font-size: 0.9rem; 
    font-weight: bold; 
    color: #555; 
    margin-bottom: 5px; 
}

.user-label { align-self: flex-end; margin-right: 20px; }
.ai-label { align-self: flex-start; margin-left: 20px; }

.home-link { 
    display: block; 
    text-align: center; 
    margin-top: 40px; 
    padding-top: 20px; 
    border-top: 2px solid #e0e0e0; 
    text-decoration: none; 
    color: #007aff; 
    font-weight: bold; 
}

/* Table Styles */
.ai-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
}

.ai-bubble th, .ai-bubble td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.ai-bubble th {
    background-color: #f2f2f2;
    font-weight: bold;
}

footer {
    margin-top: 40px;
    text-align: center;
    font-size: 0.9rem;
    color: #777;
}

footer p {
    margin: 0.5em 0;
}

.cta-section {
    background-color: #eef5ff;
    border: 1px solid #cce0ff;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    margin-top: 40px;
}

.cta-button {
    display: inline-block;
    background-color: #007aff;
    color: #ffffff;
    padding: 12px 25px;
    font-size: 1.1rem;
    font-weight: bold;
    text-decoration: none;
    border-radius: 8px;
    transition: background-color 0.2s ease-in-out;
}

.cta-button:hover {
    background-color: #0056b3;
}

.resource-item {
    border-bottom: 1px solid #eee;
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
}

dl {
    margin: 1.5rem 0;
}

dt {
    font-weight: bold;
    font-size: 1.2rem;
    color: #1a1a1a;
}

dd {
    margin-left: 0;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
}

.perspective-entry {
    margin-top: 3rem;
}

.attribution {
    font-style: italic;
    color: #555;
    font-size: 0.9rem;
}

blockquote {
    border-left: 4px solid #cce0ff;
    padding-left: 1.5rem;
    margin-left: 0;
    font-style: italic;
}

.back-to-top {
    display: block;
    text-align: right;
    margin-top: 1rem;
    font-weight: bold;
    text-decoration: none;
    color: #007aff;
}

/* Styles for the new sidebar */
.sidebar {
    width: 240px;       /* Set a fixed width for the sidebar */
    flex-shrink: 0;     /* Prevents the sidebar from shrinking */
    position: sticky;   /* Makes the sidebar stick within its container */
    top: 40px;          /* The distance from the top it should stick at */
}

.sidebar h3 {
    margin-top: 0;
}

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

.sidebar li {
    margin-bottom: 0.5rem;
}

.sidebar a {
    text-decoration: none;
    color: #555;
    display: block;
    padding: 5px 10px;
    border-radius: 5px;
    transition: all 0.2s ease-in-out;
}

.sidebar a:hover {
    background-color: #eef5ff;
    color: #007aff;
}

/* Ensure the main content area takes up the remaining space */
main {
    flex-grow: 1; /* Allows the content to fill the available space */
    min-width: 0; /* Prevents content overflow issues in flexbox */
}

.layout-sidebar {
    display: flex;
    gap: 4rem;
    align-items: flex-start;
}

/*
  By default, give the dialogue container the same properties
  as the content container for consistency.
*/
.dialogue-container {
    max-width: 800px; /* Or whatever width looks best */
    margin: 0 auto;
}

/*
  BUT, when a .dialogue-container is inside our sidebar layout,
  remove the max-width so it can fill the available space.
*/
.layout-sidebar .dialogue-container {
    max-width: none;
    margin: 0;
}

/*
  Override the default max-width for our special sidebar layout
  to give it more room to breathe.
*/
.content-container.layout-sidebar {
    max-width: 1200px; /* Or a larger value like 1100px, 1400px - experiment! */
}

/* ==========================================================================
   Responsive Design (for tablets and mobile phones)
   ========================================================================== */

/* Style the hamburger button itself */
.nav-toggle {
    display: none; /* Hide it on desktop by default */
    padding: 10px;
    background: transparent;
    border: 0;
    cursor: pointer;
    position: absolute;
    right: 2rem;
    top: 1.2rem;
    z-index: 1000;
}

.hamburger {
    display: block;
    position: relative;
}

.hamburger,
.hamburger::before,
.hamburger::after {
    background: #333;
    width: 2em;
    height: 3px;
    border-radius: 1em;
    transition: transform 0.25s ease-in-out;
}

.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
}

.hamburger::before { top: 6px; }
.hamburger::after { bottom: 6px; }

@media (max-width: 992px) { /* A common breakpoint for tablets */

    /* Make the main layout stack vertically instead of side-by-side */
    .layout-sidebar {
        flex-direction: column;
        gap: 2rem; /* Reduce the gap for a vertical layout */
    }

    /* Allow the sidebar to take up the full width */
    .sidebar {
        width: 100%;
        position: static; /* Un-stick the sidebar on mobile */
        margin-bottom: 2rem; /* Add some space below the sidebar */
        border-bottom: 2px solid #e0e0e0; /* Add a separator line */
        padding-bottom: 1rem;
    }

    /* Reduce padding on main containers for smaller screens */
    .content-container {
        padding: 1.5rem 2rem;
    }

    /* Fix the text wrapping inside the dialogue bubbles */
    .bubble {
        max-width: 90%; /* Allow bubbles to be a bit wider on mobile */
    }

    /* Ensure long words or links in bubbles don't overflow */
    .user-bubble, .ai-bubble {
        word-break: break-word;
    }

    /* Hide the full text links */
    .nav-links {
        display: none;
        position: absolute;
        top: 100%; /* Position it right below the nav bar */
        left: 0;
        right: 0;
        background-color: #ffffff;
        box-shadow: 0 5px 10px rgba(0,0,0,0.1);
    }

    nav ul {
        flex-direction: column; /* Stack the links vertically */
        align-items: center;
        padding: 1rem 0;
    }

    nav li {
        margin: 1rem 0;
    }

    /* Show the hamburger button */
    .nav-toggle {
        display: block;
    }

    /* This is the magic: when the nav has the .nav-open class... */
    .nav-open .nav-links {
        display: block; /* ...show the links! */
    }

    /* Animate the hamburger to an "X" when the menu is open */
    .nav-open .hamburger {
        transform: rotate(.625turn);
    }

    .nav-open .hamburger::before {
        transform: rotate(90deg) translateX(-6px);
    }

    .nav-open .hamburger::after {
        opacity: 0;
    }
}

@media (max-width: 480px) { /* Extra adjustments for very small phones */

    body {
        padding: 10px;
    }

    .content-container {
        padding: 1rem;
    }

    h1 {
        font-size: 2rem; /* Make the main title a bit smaller on phones */
    }
}
