:root {
    --doc-bg: #fdfdfd;
    --doc-padding: 2.5rem;
    --border-color: #dadce0;
    --toolbar-bg: #f1f3f4;
    --text-color: #202124;
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --color-legal: #d93025;
    --color-marketing: #1a73e8;
    --color-engineering: #1e8e3e;
    --color-product: #f9ab00;
    --color-ceo: #5f6368;
    --color-copyeditor: #9334e6;
}

body {
    margin: 0;
    font-family: var(--font-main);
    background-color: #e8eaed;
    color: var(--text-color);
    display: flex;
    justify-content: center;
    padding-top: 2rem;
    overflow: hidden; /* Prevents scrollbars from flashing during layout shifts */
}

.container {
    width: 100%;
    max-width: 850px;
    height: calc(100vh - 4rem);
    display: flex;
    flex-direction: column;
    background-color: var(--doc-bg);
    box-shadow: 0 1px 3px rgba(60,64,67,0.15);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

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

.title {
    font-size: 1.4rem;
    font-weight: 500;
}

.actions-container {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-avatars {
    display: flex;
    align-items: center;
    flex-direction: row-reverse;
    gap: -4px;
}

.avatar {
    width: 32px;
    height: 32px;
    max-width: 0;
    border-radius: 50%;
    border: 0 solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease, max-width 0.3s ease, border-width 0.3s ease;
    opacity: 0;
    transform: scale(0);
}

.avatar.online {
    max-width: 32px;
    border-width: 2px;
    opacity: 1;
    transform: scale(1);
}

#avatar-legal { background-color: var(--color-legal); }
#avatar-marketing { background-color: var(--color-marketing); }
#avatar-engineering { background-color: var(--color-engineering); }
#avatar-product { background-color: var(--color-product); }
#avatar-ceo { background-color: var(--color-ceo); }
#avatar-copyeditor { background-color: var(--color-copyeditor); }
#avatar-compliance { background-color: #f57c00; }

.share-btn {
    background-color: #c2e7ff;
    color: #001d35;
    border: none;
    padding: 10px 24px;
    border-radius: 100px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
}

.toolbar {
    padding: 8px var(--doc-padding);
    background-color: var(--toolbar-bg);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    color: #5f6368;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    word-spacing: 12px;
}

.document-wrapper {
    flex-grow: 1;
    overflow-y: auto;
    position: relative;
}

#document-content {
    padding: 2rem var(--doc-padding);
    line-height: 1.7;
    font-size: 11pt;
    position: relative;
}

#document-content p {
    margin-bottom: 1rem;
}

.cursor {
    position: absolute;
    opacity: 0;
    /* Cursors move instantly now, not with a transition */
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 10;
}

.cursor.visible {
    opacity: 1;
}

.cursor-bar {
    width: 2px;
    height: 1.3em;
    background-color: black;
    position: absolute;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.cursor-label {
    position: absolute;
    top: -1.6em;
    left: -4px;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
}

.highlight {
    transition: background-color 0.5s;
    border-radius: 2px;
}

#document-content h3 {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    margin-top: 2rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #5f6368;
}

#document-content p:first-of-type {
    margin-top: 0;
}

.accept-footer {
    padding: 1rem var(--doc-padding);
    border-top: 1px solid var(--border-color);
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

#accept-btn {
    padding: 10px 20px;
    font-weight: 500;
    border-radius: 4px;
    border: 1px solid transparent;
    transition: background-color 0.2s, color 0.2s;
    font-size: 0.9rem;
}

#accept-btn:disabled {
    background-color: #f1f3f4;
    color: #9aa0a6;
    border-color: #dadce0;
    cursor: not-allowed;
}

#accept-btn:not(:disabled) {
    background-color: var(--color-marketing);
    color: white;
    cursor: pointer;
}

#accept-status {
    font-size: 0.8rem;
    color: #5f6368;
}

.built-by {
    font-size: 0.8rem;
    color: #5f6368;
    margin-left: auto;
}

.built-by a {
    color: var(--color-marketing);
    text-decoration: none;
    font-weight: 500;
}

.built-by a:hover {
    text-decoration: underline;
}

.share-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #202124;
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    font-size: 0.9rem;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.share-modal.show {
    opacity: 1;
}

@media (max-width: 768px) {
    body { padding: 0; }
    .container {
        height: 100vh;
        border-radius: 0;
        border: none;
    }
    .built-by {
        margin-left: 0;
        flex-basis: 100%;
    }
    :root { --doc-padding: 1.5rem; }
    .title { font-size: 1.2rem; }
    .actions-container { gap: 1rem; }
    .share-btn { padding: 8px 16px;}
}
