:root {
    --primary-color: #e5c07b;        /* Warm yellow/orange from One Dark Pro */
    --primary-dark: #d19a66;         /* Darker orange for hover states */
    --secondary-color: #61afef;      /* Bright blue for secondary elements */
    --accent-color: #98c379;         /* Soft green for accents */
    --danger-color: #e06c75;         /* Soft red for danger/delete actions */
    --text-color: #abb2bf;           /* Light gray for main text */
    --light-text: #828997;           /* Dimmer text for secondary content */
    --border-color: #3b4048;         /* Subtle borders */
    --light-bg: #282c34;             /* Main background */
    --dark-bg: #21252b;              /* Darker background for contrast */
    --white: #abb2bf;                /* Off-white text */
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    
    /* Additional colors for better UI */
    --button-text: #ffffff;
    --card-text: #abb2bf;
    --card-light-text: #828997;
    --highlight-bg: rgba(229, 192, 123, 0.1);  /* Subtle highlight background */
    --control-bg: #1d2128;
    --control-bg-hover: #242933;
    --control-border: #4a505a;
}

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

body {
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--dark-bg);
    font-weight: 400;
}

p {
    margin-bottom: 20px;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

h1, h2, h3, h4, h5, h6 {
    /* font-family: 'VT323', 'Space Mono', 'IBM Plex Mono', monospace; */
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    color: var(--primary-color);
    text-shadow: 
        2px 2px 0 var(--dark-bg),
        3px 3px 0 var(--accent-color);
    margin-bottom: 1.2rem;
    padding-bottom: 0.5rem;
    line-height: 1.2;
}

h1 {
    font-size: 2.4rem;
}

h2 {
    font-size: 1.9rem;
    border-bottom: 2px dotted var(--primary-color);
}

h3 {
    font-size: 1.5rem;
    padding-left: 18px;
}

/* The prompt marker. It used to blink, once a second, forever, on every h3 on
   the page — five of them at once on a segment, all pulsing beside the Pali
   the reader is trying to hold in their head. A blinking thing means "waiting
   for you"; five of them permanently means nothing at all. The marker stays,
   the blink goes to the one control that really is waiting (see
   .annotation-btn.active). */
h3::before {
    content: '>';
    position: absolute;
    left: 0;
    color: var(--primary-dark);
}

h4 {
    font-size: 1.3rem;
    border-left: 3px solid var(--primary-color);
    padding-left: 10px;
}

h5, h6 {
    font-size: 1rem;
    color: var(--primary-dark);
}

/* Project title with arcade style */
#project-name {
    position: relative;
    display: inline-block;
    padding: 10px 20px;
    background: var(--dark-bg);
    border: 3px solid var(--primary-color);
    border-radius: 5px;
    box-shadow: 0 0 0 4px var(--dark-bg), 0 0 0 6px var(--border-color);
    margin-bottom: 20px;
}

/* Headings used to grow when the pointer crossed them. A heading is not a
   control, nothing happens when you click it, and text that reflows under the
   cursor while you are reading it is just noise — worse in a right-to-left or
   Indic script, where the reflow moves the diacritics. */

/* Blinking cursor animation */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

button {
    padding: 8px 16px;
    background-color: var(--primary-color);
    color: var(--dark-bg);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
}

button:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

button.danger {
    background-color: var(--danger-color);
}

button.danger:hover {
    background-color: #c62828;
}

a {
    color: var(--primary-color);
    text-decoration-color: rgba(229, 192, 123, 0.55);
    text-underline-offset: 3px;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

a:hover {
    color: var(--primary-dark);
    text-decoration-color: var(--primary-dark);
}

/* The way back from a reading page — the changelog, the instructions, the
   privacy policy — styled as the same pill as .button below, which is what it
   has always rendered as.
   
   Each of those three pages also wrote out its own .back-link rule, six
   declarations, identically. Being later in the cascade those local rules won
   any property the shared rule did not mark !important — which is exactly why
   the shared rule marked four of them !important, to win its own look back.
   The local copies are gone, so the shouting could go with them; all that
   survives from them is the margin below. */
.back-link {
    margin-bottom: 20px;
}

.button,
a.button,
.back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 14px;
    background: linear-gradient(180deg, rgba(229, 192, 123, 0.16), rgba(229, 192, 123, 0.07));
    color: var(--primary-color);
    border: 1px solid rgba(229, 192, 123, 0.55);
    border-radius: 6px;
    text-decoration: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.button:hover,
a.button:hover,
.back-link:hover {
    background: linear-gradient(180deg, rgba(229, 192, 123, 0.28), rgba(209, 154, 102, 0.12));
    border-color: var(--primary-color);
    color: #f0d39a;
    transform: translateY(-1px);
}

button.secondary {
    background: rgba(97, 175, 239, 0.08);
    border: 1px solid rgba(97, 175, 239, 0.42);
    color: #9fd0f7;
    background-color: transparent;
}

button.secondary:hover {
    background: rgba(229, 192, 123, 0.14);
    border-color: var(--primary-color);
    color: var(--primary-color);
    background-color: var(--secondary-color);
}

.button.secondary,
a.button.secondary {
    background: linear-gradient(180deg, rgba(229, 192, 123, 0.13), rgba(229, 192, 123, 0.05));
    border-color: rgba(229, 192, 123, 0.45);
    color: var(--primary-color);
}

.button.secondary:hover,
a.button.secondary:hover {
    background: rgba(229, 192, 123, 0.22);
    border-color: var(--primary-color);
    color: #f0d39a;
}

select,
input[type="text"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="password"],
textarea {
    color-scheme: dark;
    background-color: var(--control-bg);
    color: var(--text-color);
    border: 1px solid var(--control-border);
    border-radius: 6px;
    font-family: inherit;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.04),
        0 1px 0 rgba(0, 0, 0, 0.25);
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

select {
    min-height: 34px;
    padding: 7px 34px 7px 10px;
    appearance: none;
    -webkit-appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--primary-color) 50%),
        linear-gradient(135deg, var(--primary-color) 50%, transparent 50%),
        linear-gradient(90deg, rgba(229, 192, 123, 0.18), rgba(229, 192, 123, 0.18));
    background-position:
        calc(100% - 17px) 50%,
        calc(100% - 11px) 50%,
        calc(100% - 31px) 50%;
    background-size: 6px 6px, 6px 6px, 1px 60%;
    background-repeat: no-repeat;
}

select:hover,
input[type="text"]:hover,
input[type="email"]:hover,
input[type="number"]:hover,
input[type="search"]:hover,
input[type="password"]:hover,
textarea:hover {
    background-color: var(--control-bg-hover);
    border-color: rgba(229, 192, 123, 0.5);
}

select:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="password"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow:
        0 0 0 2px rgba(229, 192, 123, 0.16),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

select:disabled {
    color: var(--light-text);
    border-color: var(--border-color);
    opacity: 0.78;
}

select option {
    background-color: var(--control-bg);
    color: var(--text-color);
}

select option:checked {
    background-color: var(--primary-color);
    color: var(--dark-bg);
}

.hidden {
    display: none !important;
}

/* Auth Section */
.google-btn {
    display: inline-block;
    background-color: var(--white);
    color: var(--dark-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px 16px;
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.3s;
}

.google-btn:hover {
    background-color: var(--light-bg);
    color: var(--secondary-color);
}

#user-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

#user-name {
    font-weight: 500;
}

/* Projects View */
.projects-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.projects-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.project-card {
    background-color: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
}

.project-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    border-color: var(--primary-color);
}

.project-card h3 {
    margin-bottom: 10px;
    color: var(--primary-dark);
    font-weight: 700;
}

.project-card p {
    color: var(--card-text);
    margin-bottom: 15px;
    font-weight: 500;
}

.project-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.9em;
    color: var(--card-light-text);
    font-weight: 500;
}

/* Project Form */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
    font-size: 1em;
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

/* Project Detail View */
.project-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.project-actions {
    display: flex;
    gap: 10px;
}

#segments-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.segment-card {
    background-color: var(--light-bg);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s;
}

.segment-card:hover {
    transform: translateY(-3px);
}

.segment-card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.segment-card-content {
    color: var(--text-color);
    font-weight: 500;
    white-space: pre-wrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    /* -webkit-line-clamp: 3; */
    -webkit-box-orient: vertical;
}

.segment-content {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.original-text-section,
.analysis-section {
    background-color: var(--light-bg);
    color: var(--text-color);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow);
}

/* The three acts that cost tokens — analyse, translate, read an image — sat in
   a gapless flex column, so three full-width yellow buttons stacked flush and
   read as one slab of colour with three labels on it. They are separate acts
   with separate costs and must look like it. */
.tools-section {
    display: flex;
    flex-flow: row wrap;
    gap: 10px;
    align-items: center;
}

.editable-content {
    min-height: 100px;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin: 10px 0;
    background-color: var(--light-bg);
    color: var(--text-color);
    font-weight: 500;
    white-space: pre-wrap;
}

.editable-content:focus {
    outline: 2px solid var(--primary-color);
}

.conversation-section {
    background-color: var(--light-bg);
    color: var(--text-color);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow);
}

#conversation-messages {
    max-height: 400px;
    overflow-y: auto;
    padding: 15px;
    background-color: var(--dark-bg);
    color: var(--text-color);
    border-radius: 8px;
    margin-bottom: 15px;
}

/* The chat turn styling used to live here as well as further down this file:
   two full sets of rules for .message, .message.user, .message.assistant and
   .message-content, written at different times and disagreeing about almost
   everything — one made the row a block with a coloured left edge, the other
   made it a flex container with a bubble inside it, so what rendered was a
   bubble nested inside a slab of the same colour. The surviving definition is
   the one below.

   Its .message-content strong was also #555 — near-black grey on both the dark
   panel and the yellow bubble, so the "You:" and "Assistant:" labels were
   almost unreadable on either. */

/* Clear the float after messages */
#conversation-messages::after {
    content: "";
    display: table;
    clear: both;
}

#chat-input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 1em;
    background-color: var(--dark-bg);
    color: var(--text-color);
}

#send-message-btn {
    padding: 0 20px;
    border-radius: 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .project-header,
    .projects-header,
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    /* Update user section for mobile */
    #user-section {
        width: 100%;
        justify-content: space-between;
    }
    
    .project-actions {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .projects-list {
        grid-template-columns: 1fr;
    }
    
    /* Add hamburger menu for very small screens */
    @media (max-width: 480px) {
        header {
            position: relative;
        }
        
        #nav-toggle {
            display: block;
            background: none;
            border: none;
            color: var(--primary-color);
            font-size: 1.5rem;
            cursor: pointer;
            position: absolute;
            top: 15px;
            right: 15px;
            z-index: 100;
        }
        
        .nav-menu {
            display: none;
            width: 100%;
            flex-direction: column;
            gap: 10px;
            margin-top: 10px;
        }
        
        .nav-menu.active {
            display: flex;
        }
        
        /* Stack buttons vertically on very small screens */
        .project-actions {
            flex-direction: column;
            align-items: stretch;
        }
        
        .project-actions button {
            margin-bottom: 8px;
        }
    }
}

.back-to-projects-btn {
    background-color: var(--light-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 10px;
    font-weight: 600;
}

.back-to-projects-btn:hover {
    background-color: var(--border-color);
}

/* Add Google Font */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
    margin-left: 5px;
}

/* Friend Items */
.friend-item {
    background-color: var(--light-bg);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.friend-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.friend-info h4 {
    color: var(--text-color);
    margin: 0;
    font-weight: 600;
}

.friend-info p {
    color: var(--light-text);
    margin: 0;
    font-size: 0.9em;
}

/* Add styling for shared projects */
.sharing-info {
    background-color: var(--accent-color);
    color: var(--secondary-color);
    padding: 5px 10px;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 0.9em;
    font-weight: 600;
}

/* Add a subtle border for shared projects */
.project-card.shared {
    border-left: 4px solid var(--accent-color);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 126, 0, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* For streaming responses */
.typing-indicator {
    display: inline-block;
    animation: typing 1.5s infinite;
    font-weight: bold;
    width: auto;
    font-size: 1.2em;
    letter-spacing: 2px;
}

@keyframes typing {
    0% { opacity: 0.3; }
    50% { opacity: 1; }
    100% { opacity: 0.3; }
}

.tag-filter {
    margin-bottom: 20px;
    position: relative;
}

#tag-filter {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--dark-bg);
    color: var(--text-color);
    font-size: 1rem;
}

.active-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.active-tag {
    display: inline-flex;
    align-items: center;
    background-color: var(--primary-color);
    color: var(--dark-bg);
    padding: 4px 8px;
    border-radius: 16px;
    font-size: 0.9rem;
    font-weight: 500;
}

.remove-tag {
    background: none;
    border: none;
    color: var(--dark-bg);
    margin-left: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 4px;
    border-radius: 50%;
}

.remove-tag:hover {
    background-color: rgba(0, 0, 0, 0.2);
}

.clear-all-tags {
    margin-top: 10px;
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.clear-all-tags:hover {
    background-color: var(--light-bg);
}

/* Make project tags clickable */
.tag {
    cursor: pointer;
    transition: transform 0.2s;
    display: inline-block;
    background-color: var(--accent-color);
    color: var(--dark-bg);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
    margin-right: 5px;
    margin-bottom: 5px;
}

.tag:hover {
    transform: scale(1.05);
    background-color: var(--primary-color);
    color: var(--dark-bg);
}

.annotations-list {
    margin-bottom: 15px;
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 15px;
}

.conversation-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* One row per turn. The row positions the bubble; the bubble carries the
   colour. The row itself must not also be a coloured box, which is what the
   two competing definitions between them produced. */
.message {
    display: flex;
    margin-bottom: 15px;
}

.message.user {
    justify-content: flex-end;
    margin-left: 15%;
}

.message.assistant,
.message.jam {
    justify-content: flex-start;
    margin-right: 15%;
}

.message.system {
    align-self: center;
    background-color: rgba(231, 76, 60, 0.1);
    border-left: 3px solid var(--danger-color);
    padding: 8px 12px;
    border-radius: 4px;
    max-width: 90%;
}

.message-content {
    padding: 10px 15px;
    border-radius: 12px;
    background-color: var(--light-bg);
    border: 1px solid var(--border-color);
    max-width: 100%;
    overflow-wrap: anywhere;
}

.message-content strong {
    display: block;
    margin-bottom: 4px;
    font-size: 0.82rem;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--light-text);
}

/* The reader's own words, in the app's accent, dark text on light so the
   Devanagari and diacritics stay legible at small sizes. */
.message.user .message-content {
    background-color: var(--primary-color);
    border-color: var(--primary-dark);
    color: var(--dark-bg);
    border-top-right-radius: 4px;
}

.message.user .message-content strong {
    color: rgba(33, 37, 43, 0.7);
}

.message.assistant .message-content {
    background-color: var(--light-bg);
    border-top-left-radius: 4px;
}

.chat-input-container {
    display: flex;
    gap: 10px;
    padding: 15px 0;
    border-top: 1px solid var(--border-color);
    margin-top: 15px;
}

.chat-input-container textarea {
    flex: 1;
    padding: 10px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background-color: var(--dark-bg);
    color: var(--text-color);
    resize: none;
    min-height: 40px;
    max-height: 120px;
}

.chat-input-container button {
    border-radius: 20px;
    padding: 0 20px;
}

/* Code formatting in messages */
.message-content code {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
}

.message-content pre {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 10px 0;
}

.message-content pre code {
    background-color: transparent;
    padding: 0;
}

/* The waiting strip: what needs this reader's answer, above the work. Sits at
   the top of the landing surface, and renders nothing at all when the answer
   is "nothing" — a strip that says "no requests" every day teaches readers to
   stop reading it. */
.waiting-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    margin-bottom: 24px;
    padding: 12px 16px;
    background-color: var(--highlight-bg);
    border: 1px solid rgba(229, 192, 123, 0.35);
    border-radius: 4px;
}

.waiting-line {
    margin: 0;
    flex: 1 1 260px;
    min-width: 0;
}

.waiting-action {
    padding: 4px 12px;
    background-color: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    font-size: 0.9rem;
}

.waiting-action:hover {
    background-color: var(--primary-color);
    color: var(--dark-bg);
}

.request-actions {
    display: flex;
    gap: 10px;
}

/* Collaborative project styling */
.project-card.collaborative {
    border-left: 4px solid var(--accent-color);
}

.sharing-info.collaborative {
    background-color: var(--accent-color);
    color: var(--dark-bg);
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.8em;
    display: inline-block;
    margin-top: 5px;
}

/* Collaborative project indicator */
.collaborative-indicator {
    background-color: var(--accent-color);
    color: var(--white);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.9em;
    margin: 0 15px;
    display: inline-block;
}

/* Annotation styles */
.annotation-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.annotation-btn {
    padding: 6px 12px;
    border-radius: 4px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    margin-right: 10px;
    margin-right: 10px;
}

.annotation-btn.active {
    animation: pulse 1.5s infinite;
    background-color: var(--accent-color);
    background-color: var(--accent-color);
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.color-picker {
    display: flex;
    gap: 5px;
    margin-top: 5px;
}

.color-option {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
    border: 2px solid transparent;
    border: 2px solid transparent;
}

.color-option:hover {
    transform: scale(1.2);
}

.color-option.selected {
    box-shadow: 0 0 0 2px white, 0 0 0 4px black;
    border-color: var(--white);
    border-color: var(--white);
}

.annotation-item {
    background-color: var(--light-bg);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 10px;
}

.annotation-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 0.8em;
    color: var(--text-color);
}

.annotation-text {
    margin: 8px 0;
    font-style: italic;
    color: #555;
}

.annotation-comment {
    margin: 8px 0;
    background-color: #f9f9f9;
    padding: 8px;
    border-radius: 4px;
    color: #333;
}

.delete-annotation-btn {
    background-color: var(--danger-color);
    color: white;
    padding: 3px 8px;
    font-size: 0.8em;
}

/* Placed at the selection: only left/top come from JS, and they need
   something positioned to apply to. */
.annotation-form {
    position: absolute;
    background-color: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px;
    box-shadow: var(--shadow);
    z-index: 1000;
    max-width: 300px;
    color: var(--text-color);
}

.annotation-form textarea {
    width: 100%;
    min-height: 80px;
    margin-bottom: 10px;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--dark-bg);
    color: var(--text-color);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Make annotatable elements clearly indicate they accept annotations */
.annotatable {
    position: relative;
}

.annotatable:hover::after {
    content: "Select text to annotate";
    position: absolute;
    top: -25px;
    right: 0;
    background-color: #f0f0f0;
    padding: 3px 6px;
    border-radius: 3px;
    font-size: 0.8em;
    color: #333;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.highlighted-text {
    cursor: pointer;
    border-radius: 2px;
    padding: 0 2px;
    transition: opacity 0.3s;
}

.highlighted-text:hover {
    opacity: 0.7;
}

/* Flash effect for finding annotations */
@keyframes highlightFlash {
    0% { background-color: rgba(255, 126, 0, 0.2); }
    50% { background-color: rgba(255, 126, 0, 0.5); }
    100% { background-color: rgba(255, 126, 0, 0.2); }
}

/* Make sure annotations are always displayed below their respective content */
#original-annotation-section {
    order: 3; /* After original text section */
}

#translation-annotation-section {
    order: 5; /* After translation section */
}

/* The superadmin's way into the back office. One fixed row so the two links
   cannot overlap whatever their widths. */
.back-button-row {
    margin-bottom: 15px;
}

.admin-links-row {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    gap: 8px;
}

.admin-link {
    display: inline-block;
    padding: 5px 10px;
    background-color: var(--primary-dark);
    color: var(--dark-bg);
    border-radius: 4px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.3s ease;
}

/* The two destinations, told apart by colour rather than by reading them. */
.admin-link-lab {
    background-color: #c678dd;
}

.admin-link-admin {
    background-color: var(--primary-color);
}

.admin-link:hover {
    background-color: var(--primary-color);
    transform: translateY(-2px);
}

/* Responsive Navigation - Add after the header styles */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 30px;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 15px; /* Add space between wrapped elements */
    gap: 15px;
}

/* Add/Update responsive styles */
@media (max-width: 768px) {
    .project-header,
    .projects-header,
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    /* Update user section for mobile */
    #user-section {
        width: 100%;
        justify-content: space-between;
    }
    
    .project-actions {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .projects-list {
        grid-template-columns: 1fr;
    }
    
    /* Footer responsive */
    .footer-content {
        flex-direction: column;
        gap: 10px;
    }
    
    /* Add hamburger menu for very small screens */
    @media (max-width: 480px) {
        header {
            position: relative;
        }
        
        #nav-toggle {
            display: block;
            background: none;
            border: none;
            color: var(--primary-color);
            font-size: 1.5rem;
            cursor: pointer;
            position: absolute;
            top: 15px;
            right: 15px;
            z-index: 100;
        }
        
        .nav-menu {
            display: none;
            width: 100%;
            flex-direction: column;
            gap: 10px;
            margin-top: 10px;
        }
        
        .nav-menu.active {
            display: flex;
        }
        
        /* Stack buttons vertically on very small screens */
        .project-actions {
            flex-direction: column;
            align-items: stretch;
        }
        
        .project-actions button {
            margin-bottom: 8px;
        }
    }
}

/* Make sure buttons don't overflow on small screens */
button, .google-btn {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
  
  .instructions-container {
    max-width: 800px;
    margin: 20px auto;
    padding: 20px;
    border-radius: 8px;
    background-color: var(--light-bg, #2a2a2a);
    border: 1px solid var(--border-color, #444);
    color: var(--text-color, #e0e0e0);
    font-family: 'VT323', 'IBM Plex Mono', monospace;
  }
  
  .instructions-container h2 {
    text-align: center;
    color: var(--primary-color, #f5a623);
    margin-bottom: 20px;
    border-bottom: 1px dotted var(--primary-color, #f5a623);
    padding-bottom: 10px;
  }
  
  .instructions-container h3 {
    color: var(--primary-color, #f5a623);
    margin-top: 20px;
    margin-bottom: 10px;
  }
  
  .instructions-content {
    line-height: 1.6;
  }
  
  .instructions-content ul {
    list-style-type: square;
    margin-left: 20px;
    margin-bottom: 15px;
  }
  
  .instructions-content strong {
    color: var(--accent-color, #ff6b6b);
    font-weight: bold;
  }
  
  .instructions-content a {
    color: var(--primary-color, #f5a623);
    text-decoration: underline;
  }
  
  .instructions-content a:hover {
    text-decoration: none;
  }
  
  /* Make sure to add this modal-like functionality for mobile views */
  @media (max-width: 768px) {
    .instructions-container {
      padding: 15px;
      margin: 10px;
      max-height: 400px;
      overflow-y: auto;
    }
    
    .instructions-content {
      font-size: 0.9rem;
    }
  }

/* Searchable Dropdown Styles */
.searchable-dropdown {
    position: relative;
    width: 100%;
}

.dropdown-search {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--dark-bg);
    color: var(--text-color);
    font-family: inherit;
    font-size: 1em;
}

.dropdown-content {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
    background-color: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: 0 0 4px 4px;
    z-index: 100;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.dropdown-content h4 {
    margin: 0;
    padding: 10px;
    background-color: var(--dark-bg);
    color: var(--primary-color);
    font-size: 0.9em;
    border-bottom: 1px solid var(--border-color);
}

.dropdown-item {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dropdown-item:hover {
    background-color: var(--dark-bg);
}

.dropdown-separator {
    height: 1px;
    background-color: var(--border-color);
    margin: 5px 0;
}

.pinned-languages-section {
    border-bottom: 1px solid var(--border-color);
}

.dropdown-item.pinned {
    background-color: rgba(229, 192, 123, 0.1);
}

.pin-language-btn,
.unpin-language-btn {
    background: none;
    border: none;
    font-size: 1em;
    cursor: pointer;
    padding: 2px 5px;
    color: var(--light-text);
}

.pin-language-btn:hover,
.unpin-language-btn:hover {
    color: var(--primary-color);
}

.no-results {
    padding: 10px;
    text-align: center;
    color: var(--light-text);
    font-style: italic;
} 

.sort-toggle-container {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.sort-toggle-btn {
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
}

.sort-toggle-btn:hover {
    background-color: #e9e9e9;
}

.sort-icon {
    font-weight: bold;
    font-size: 16px;
}
/* Add styles for annotation context label */
.annotation-context {
    font-size: 12px;
    background-color: #f0f0f0;
    border-radius: 4px;
    padding: 2px 6px;
    margin-left: 8px;
    color: #666;
}

/* Add styles for model selectors */
/* Now a <details>: a flex row cannot hold a fold, because the summary has to
   be the whole first line and the controls have to sit under it. */
.model-selectors {
    margin: 12px 0 18px;
    padding: 12px 14px;
    display: block;
    background:
        linear-gradient(180deg, rgba(40, 44, 52, 0.92), rgba(33, 37, 43, 0.92)),
        radial-gradient(circle at top left, rgba(229, 192, 123, 0.14), transparent 42%);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

/* The summary carries the one fact worth glancing at: which model, at what
   cost. It reads as a line of text, not as a control. */
.model-selectors > summary {
    cursor: pointer;
    color: var(--light-text);
    font-size: 0.9rem;
    list-style: none;
}

.model-selectors > summary::before {
    content: '▸ ';
    color: var(--primary-dark);
}

.model-selectors[open] > summary {
    color: var(--text-color);
    margin-bottom: 12px;
}

.model-selectors[open] > summary::before {
    content: '▾ ';
}

.model-selectors > summary:hover {
    color: var(--primary-color);
}

.model-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.model-selectors[open] .model-selector + .model-selector {
    margin-top: 10px;
}

.model-selector label {
    color: var(--light-text);
    font-size: 0.92rem;
    letter-spacing: 0.02em;
}

#translation-method-selector {
    min-width: 150px;
}

#ai-model-selector {
    min-width: min(360px, 78vw);
}

#conversation-selector {
    min-width: min(285px, 52vw);
}

.conversation-actions {
    align-items: center;
    display: flex;
    gap: 10px;
}

/* Add highlight flash effect */
@keyframes highlight-flash {
    0% { background-color: transparent; }
    25% { background-color: rgba(255, 126, 0, 0.3); }
    75% { background-color: rgba(255, 126, 0, 0.3); }
    100% { background-color: transparent; }
}

.highlight-flash {
    animation: highlight-flash 1.5s ease-in-out;
}

/* Footer styles */
footer {
    margin-top: 50px;
    padding: 22px 20px;
    background:
        linear-gradient(180deg, rgba(33, 37, 43, 0.8), rgba(29, 33, 40, 1));
    border-top: 1px solid var(--border-color);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-links a {
    display: inline-flex;
    align-items: center;
    color: var(--primary-color);
    text-decoration: none;
    margin: 4px 10px 4px 0;
    padding: 5px 9px;
    border: 1px solid rgba(229, 192, 123, 0.28);
    border-radius: 999px;
    background-color: rgba(229, 192, 123, 0.06);
    font-size: 0.9rem;
}

.footer-links a:hover {
    color: var(--dark-bg);
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    text-decoration: none;
}

.footer-copyright {
    color: var(--light-text);
    font-size: 0.9rem;
}

/* ---------------------------------------------------------------------------
   Notices

   The non-blocking replacement for window.alert(). Stacked in the bottom-right
   corner so they never cover the text being read (which sits top-left), and
   never take the caret out of a field mid-sentence.
   --------------------------------------------------------------------------- */
.notices {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    /* The stack itself must not swallow clicks on whatever is underneath it. */
    pointer-events: none;
    max-width: min(420px, calc(100vw - 40px));
}

.notice {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    background-color: var(--dark-bg);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--light-text);
    border-radius: 4px;
    box-shadow: var(--shadow);
    color: var(--text-color);
    font-size: 0.92rem;
    line-height: 1.45;
    animation: notice-in 160ms ease-out;
}

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

@media (prefers-reduced-motion: reduce) {
    .notice { animation: none; }
}

.notice-ok    { border-left-color: var(--accent-color); }
.notice-info  { border-left-color: var(--secondary-color); }
.notice-warn  { border-left-color: var(--primary-color); }
.notice-error { border-left-color: var(--danger-color); }

.notice-text {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.notice-dismiss {
    flex: none;
    padding: 0 4px;
    background: none;
    border: none;
    color: var(--light-text);
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
}

.notice-dismiss:hover {
    color: var(--text-color);
    background: none;
}

/* ---------------------------------------------------------------------------
   Autosave state lines

   Each editable panel used to end in a Save button. It ends in one of these
   instead: a quiet line reporting where that panel's text stands. Quiet is the
   point — a save the reader did not ask for should not draw the eye. The one
   loud state is "Not saved", because then the screen and the server disagree.
   --------------------------------------------------------------------------- */
.save-state {
    min-height: 1.4em;
    margin-top: 6px;
    font-size: 0.82rem;
    color: var(--light-text);
}

.save-state-saving,
.save-state-dirty {
    font-style: italic;
}

.save-state-saved {
    color: var(--accent-color);
}

.save-state-failed {
    color: var(--danger-color);
    font-weight: 500;
}

.save-state-retry {
    padding: 1px 8px;
    font-size: 0.82rem;
    background-color: transparent;
    border: 1px solid var(--danger-color);
    border-radius: 3px;
    color: var(--danger-color);
    cursor: pointer;
}

.save-state-retry:hover {
    background-color: var(--danger-color);
    color: var(--dark-bg);
}

/* ---------------------------------------------------------------------------
   Walking the text
   --------------------------------------------------------------------------- */
.segment-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.segment-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.segment-position {
    color: var(--light-text);
    font-size: 0.9rem;
    white-space: nowrap;
}

/* The ends of a text are worth seeing rather than guessing at, so the button
   stays in place and goes quiet. */
.segment-nav button:disabled {
    opacity: 0.4;
    cursor: default;
}

/* A hint that belongs to the field above it, not a paragraph of its own. */
.form-hint {
    margin: 6px 0 0;
    color: var(--light-text);
    font-size: 0.85rem;
    line-height: 1.4;
}

/* An empty section says what fills it, so it reads as an invitation rather
   than as an absence. Per-section wording differs on purpose: three lists all
   saying "nothing here" teach nothing about which one you can act on. */
.empty-state {
    margin: 0;
    padding: 14px 16px;
    background-color: var(--light-bg);
    border: 1px dashed var(--border-color);
    border-radius: 4px;
    color: var(--light-text);
    line-height: 1.5;
}

.empty-state b {
    color: var(--text-color);
    font-weight: 500;
}

/* Inside a card grid, the empty state is a sentence, not a card: it spans the
   whole row instead of pretending to be the first of several columns. */
.projects-list > .empty-state,
.segments-container > .empty-state {
    grid-column: 1 / -1;
}

/* ---------------------------------------------------------------------------
   The danger fold

   The one control that can destroy a whole text. Folded shut, at the foot of
   the page, well below the segments — it must never be somewhere a hand goes
   while scanning for a passage. Opening it states what would be lost before
   the button is reachable.
   --------------------------------------------------------------------------- */
.danger-zone {
    margin-top: 40px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.danger-zone > summary {
    cursor: pointer;
    color: var(--light-text);
    font-size: 0.9rem;
    list-style: none;
}

.danger-zone > summary::before {
    content: '▸ ';
}

.danger-zone[open] > summary::before {
    content: '▾ ';
}

.danger-zone > summary:hover {
    color: var(--danger-color);
}

.danger-zone > p {
    margin: 12px 0;
    max-width: 60ch;
    color: var(--text-color);
    font-size: 0.92rem;
}

/* ---------------------------------------------------------------------------
   Chat turns

   The transcript is prose, so it is rendered as text and keeps the line breaks
   the writer put in it. A "jam" is the app speaking in its own name when
   something went wrong — visibly not a turn of the conversation, because it
   must never be mistaken for something a model said.
   --------------------------------------------------------------------------- */
.message-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.message.jam .message-content {
    border-color: var(--danger-color);
    background-color: rgba(224, 108, 117, 0.08);
    color: var(--light-text);
    font-size: 0.92rem;
}

.message.jam .message-content strong {
    color: var(--danger-color);
}

/* One chat is not a choice. The list appears when there is something to pick. */
#conversation-selector.hidden {
    display: none;
}

/* ---------------------------------------------------------------------------
   Dialogs

   There was no styling for these at all. The markup has always described an
   overlay — a surround, a panel, a header with a close control — but nothing
   ever positioned it, so "opening a dialog" appended a bare div to the end of
   the document and left the reader looking at an unchanged page with a form
   sitting below the footer, off-screen until they scrolled to find it.
   --------------------------------------------------------------------------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1500;
    display: none;
    padding: 24px 16px;
    overflow-y: auto;
    background-color: rgba(0, 0, 0, 0.66);
}

.modal-content {
    max-width: 560px;
    margin: 0 auto;
    background-color: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: var(--shadow);
    /* Keeps a long collaborator list inside the panel rather than letting the
       panel grow past the bottom of the window. */
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px 0;
}

.modal-header h3 {
    margin: 0;
    padding-left: 0;
    font-size: 1.15rem;
    text-shadow: none;
    overflow-wrap: anywhere;
}

/* The arcade blink belongs to section headings, not to a dialog title. */
.modal-header h3::before {
    content: none;
}

.close-modal {
    flex: none;
    padding: 0 6px;
    background: none;
    border: none;
    color: var(--light-text);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.close-modal:hover {
    background: none;
    color: var(--text-color);
    transform: none;
}

.modal-body {
    padding: 16px 20px 20px;
    overflow-y: auto;
}

.modal-body .form-group {
    margin-bottom: 16px;
}

.modal-body .form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 6px;
}

.radio-group > label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.45;
    cursor: pointer;
}

/* Without this the radio is a flex item free to stretch, and it drifts a long
   way from the words it belongs to. */
.radio-group input[type="radio"] {
    flex: none;
    width: auto;
    margin-top: 0.35em;
}

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

.collaborator-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.collaborator-item:last-child {
    border-bottom: none;
}

.collaborator-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.collaborator-email {
    color: var(--light-text);
    font-size: 0.85rem;
    overflow-wrap: anywhere;
}

.collaborator-role {
    color: var(--secondary-color);
    font-size: 0.85rem;
}

/* ---------------------------------------------------------------------------
   Reduced motion

   Everything above that moves — the spinner, the typing dots, the pulse on an
   armed annotation button, hover lifts, notice entrances — stops here. The
   Warhog and research pages already honoured this setting; the reader, which
   is where someone sits for an hour with a difficult text, did not honour it
   anywhere.

   Animations are not merely slowed: `animation: none` would strip the spinner
   entirely and leave no sign that anything was happening, so the ones that
   carry meaning keep running at a rate that does not flicker.
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    /* Decorative motion: gone. */
    .annotation-btn.active,
    .tag:hover,
    .color-option:hover,
    button:hover,
    .button:hover,
    a.button:hover,
    .back-link:hover {
        animation: none !important;
        transform: none !important;
    }

    /* Motion that reports progress: kept, but slow and steady rather than
       flickering, because removing it would remove the only sign of work. */
    .spinner,
    .spinner-small {
        animation-duration: 2s !important;
    }

    .typing-indicator {
        animation-duration: 3s !important;
    }
}

/* The two folds on the sign-in page. Furniture: read once, then never again. */
.login-fold {
    margin-bottom: 16px;
    padding: 14px 18px;
    background-color: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.login-fold > summary {
    cursor: pointer;
    color: var(--primary-color);
    font-weight: 500;
}

.login-fold > summary:hover {
    color: var(--primary-dark);
}

.login-fold > p {
    margin: 14px 0 0;
    max-width: 68ch;
}

/* ---------------------------------------------------------------------------
   What things cost
   --------------------------------------------------------------------------- */
.token-count {
    color: var(--light-text);
    font-size: 0.88rem;
    white-space: nowrap;
}

.token-count-low {
    color: var(--primary-color);
}

.token-count-empty {
    color: var(--danger-color);
    font-weight: 500;
}

/* An action the current balance will not cover. Still pressable — the server
   is the authority on the charge, and it may be cheaper than the estimate —
   but it should not look like the others. */
button.too-expensive {
    background-color: transparent;
    border: 1px dashed var(--danger-color);
    color: var(--danger-color);
}

button.too-expensive:hover {
    background-color: rgba(224, 108, 117, 0.12);
    color: var(--danger-color);
}

/* A statement of fact at the top of a dialog — what is true right now, before
   the reader changes it. */
.dialog-fact {
    margin: 0 0 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--light-text);
}

.dialog-fact strong {
    color: var(--text-color);
}
