/* CSS Variables - Dark Theme */
:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #151515;
    --bg-tertiary: #1f1f1f;
    --text-primary: #e5e5e5;
    --text-secondary: #a8a8a8;
    --text-tertiary: #6b6b6b;
    --border: #2a2a2a;
    --accent: #8b2bd6;
    --accent-hover: #a345ed;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

.hidden {
    display: none !important;
}

/* Login Page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.login-box p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.login-box input {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 1rem;
}

.login-box button {
    width: 100%;
    padding: 0.75rem;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.login-box button:hover {
    background: var(--accent-hover);
}

.error-message {
    color: var(--error);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Clerk SignIn container */
#clerk-sign-in {
    min-height: 200px;
}

/* App-specific overrides */
.chat-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-header-left h2 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.username-display {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.header-separator {
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

.logout-link {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0;
}

.logout-link:hover {
    color: var(--text-primary);
}

.token-counter {
    padding: 0.25rem;
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border: 1px solid #22c55e;
    border-radius: var(--radius-sm);
    font-size: 7px;
    font-family: monospace;
    white-space: nowrap;
}

.version-badge {
    padding: 0.375rem 0.5rem;
    background: rgba(59, 130, 246, 0.2);
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-family: monospace;
}

.settings-btn {
    padding: 0.5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.settings-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.settings-btn svg {
    width: 20px;
    height: 20px;
    display: block;
}

.font-size-options {
    display: grid;
    gap: 0.5rem;
}

.font-size-option {
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.font-size-option:hover {
    background: var(--bg-secondary);
}

.font-size-option.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Thinking indicator */
@keyframes pulse-thinking {
    0%, 100% {
        opacity: 0.4;
        transform: scale(0.95);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

.thinking-indicator {
    animation: pulse-thinking 1.5s ease-in-out infinite;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    max-width: fit-content;
}

.thinking-dots {
    display: flex;
    gap: 0.25rem;
}

.thinking-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
}

.thinking-dot:nth-child(1) {
    animation: pulse-thinking 1.5s ease-in-out infinite;
}

.thinking-dot:nth-child(2) {
    animation: pulse-thinking 1.5s ease-in-out 0.2s infinite;
}

.thinking-dot:nth-child(3) {
    animation: pulse-thinking 1.5s ease-in-out 0.4s infinite;
}

/* App Layout */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 100;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--accent);
    cursor: pointer;
}

.mobile-menu-btn svg {
    width: 16px;
    height: 16px;
    display: block;
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
}

.mobile-overlay.active {
    display: block;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border);
}

.new-chat-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s;
}

.new-chat-btn:hover {
    background: var(--accent-hover);
}

.sidebar-actions {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-actions button {
    width: 100%;
    padding: 0.75rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.sidebar-actions button:hover {
    background: var(--accent-hover);
}

.sessions-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.session-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.25rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.2s;
}

.session-item:hover {
    background: var(--bg-tertiary);
}

.session-item.active {
    background: var(--bg-tertiary);
}

.session-item-content {
    flex: 1;
    min-width: 0;
}

.session-item-title {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-item-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.project-tag {
    display: inline-block;
    background: var(--accent);
    color: white;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.625rem;
    margin-left: 0.5rem;
    text-transform: uppercase;
    font-weight: 500;
}

.session-item-actions {
    display: none;
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    gap: 0.25rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 0.125rem;
}

.session-item:hover .session-item-actions {
    display: flex;
}

.session-action-btn {
    padding: 0.25rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.session-action-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-username {
    color: var(--text-primary);
    font-size: 0.875rem;
}

.sidebar-separator {
    color: var(--text-tertiary);
}

.sidebar-footer button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0;
}

.sidebar-footer button:hover {
    color: var(--text-primary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    padding: 0;
    border-bottom: 1px solid var(--border);
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

/* Message Styles */
.message {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.message-role {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.message-content {
    padding: 0.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    line-height: 1.5;
}

.message.user .message-content {
    background: var(--bg-tertiary);
}

.message.assistant .message-content {
    background: var(--bg-secondary);
}

/* TTS Button */
.message.assistant {
    position: relative;
}

.tts-button {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s;
}

.message.assistant:hover .tts-button {
    opacity: 1;
}

.tts-button:hover {
    background: var(--accent);
    color: white;
}

.tts-button.loading {
    opacity: 1;
    background: var(--bg-tertiary);
    color: var(--accent);
}

.tts-button.loading svg {
    animation: spin 1s linear infinite;
}

.tts-button.speaking {
    opacity: 1;
    background: var(--accent);
    color: white;
    animation: pulse 1s ease-in-out infinite;
}

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

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

/* Tool Call/Result Styles */
.message.tool-call,
.message.tool-result {
    margin: 0.5rem 0;
}

.tool-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.tool-header:hover {
    background: var(--bg-secondary);
    border-color: var(--accent);
}

.tool-icon {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    width: 12px;
    text-align: center;
}

.tool-name {
    font-weight: 500;
    color: var(--text-primary);
}

.tool-content {
    margin-top: 0.25rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow-x: auto;
}

.tool-content pre {
    margin: 0;
    background: none;
    padding: 0;
}

.tool-content code {
    font-size: 0.813rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* Markdown Content Styling */
.message-content p {
    margin-bottom: 1em;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
    line-height: 1.3;
}

.message-content h1:first-child,
.message-content h2:first-child,
.message-content h3:first-child {
    margin-top: 0;
}

.message-content h1 {
    font-size: 1.5em;
}

.message-content h2 {
    font-size: 1.3em;
}

.message-content h3 {
    font-size: 1.1em;
}

.message-content code {
    background: var(--bg-tertiary);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.9em;
}

.message-content pre {
    background: var(--bg-tertiary);
    padding: 1em;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 1em 0;
}

.message-content pre code {
    background: none;
    padding: 0;
    font-size: 0.875em;
    line-height: 1.5;
}

.message-content ul,
.message-content ol {
    margin: 1em 0;
    padding-left: 2em;
}

.message-content li {
    margin: 0.5em 0;
}

.message-content li > p {
    margin-bottom: 0.5em;
}

.message-content blockquote {
    border-left: 3px solid var(--border);
    padding-left: 1em;
    margin: 1em 0;
    color: var(--text-secondary);
}

.message-content a {
    color: var(--accent);
    text-decoration: none;
}

.message-content a:hover {
    text-decoration: underline;
}

.message-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5em 0;
}

.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}

.message-content th,
.message-content td {
    border: 1px solid var(--border);
    padding: 0.5em;
    text-align: left;
}

.message-content th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

/* Input Container */
.input-container {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.input-wrapper textarea {
    flex: 1;
    min-height: 60px;
    max-height: 200px;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    resize: vertical;
}

.input-wrapper textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.input-wrapper button {
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.input-wrapper button:hover {
    background: var(--accent-hover);
}

.input-wrapper button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.modal-message {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-input {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
}

.modal-input:focus {
    outline: none;
    border-color: var(--accent);
}

.modal-select {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
}

.modal-select:focus {
    outline: none;
    border-color: var(--accent);
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    justify-content: flex-end;
}

.modal-btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.workspace-option {
    width: 100%;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.workspace-option:hover {
    background: var(--bg-primary);
    border-color: var(--accent);
}

.workspace-option:last-child {
    margin-bottom: 0;
}

.modal-cancel {
    padding: 0.75rem 1.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.modal-cancel:hover {
    background: var(--bg-primary);
}

.modal-btn-cancel {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.modal-btn-cancel:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-btn-confirm {
    background: var(--accent);
    border: none;
    color: white;
}

.modal-btn-confirm:hover {
    background: var(--accent-hover);
}

.modal-btn-danger {
    background: var(--error);
    border: none;
    color: white;
}

.modal-btn-danger:hover {
    background: #dc2626;
}

/* Share Modal */
.share-modal {
    min-width: 350px;
}

.share-input-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.share-select {
    flex: 1;
    padding: 0.625rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.share-select:focus {
    outline: none;
    border-color: var(--accent);
}

.share-error {
    color: var(--error);
    font-size: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: rgba(239, 68, 68, 0.1);
    border-radius: var(--radius-sm);
}

.shares-list h4 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

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

.shares-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.shares-list li:last-child {
    border-bottom: none;
}

.shares-empty {
    color: var(--text-tertiary);
    font-size: 0.875rem;
    font-style: italic;
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

.share-btn {
    margin-left: 0.5rem;
    opacity: 0.6;
    transition: opacity 0.2s;
    vertical-align: middle;
}

.share-btn:hover {
    opacity: 1;
}

.lake-header-left h2 {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    color: var(--text-primary);
}

/* Font Size Classes - Using CSS custom property for instant updates */
body.text-xs { --app-font-size: 0.75rem; }
body.text-sm { --app-font-size: 0.875rem; }
body.text-base { --app-font-size: 1rem; }
body.text-lg { --app-font-size: 1.125rem; }

/* Apply font size to key content areas */
.messages-container,
.message-content,
.chat-input,
.entity-viewer,
.entity-content,
.sidebar,
.conversation-item,
.claude-sidebar,
.input-wrapper textarea,
.sidebar-input textarea {
    font-size: var(--app-font-size, 0.875rem);
}

/* Hide Tool Calls Toggle */
.hide-tool-calls .message.tool-call,
.hide-tool-calls .message.tool-result {
    display: none !important;
}

/* Toggle Switch Styling */
.toggle-setting {
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-setting:hover {
    background: var(--bg-secondary);
}

.toggle-setting input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 50%;
    right: 0.75rem;
    transform: translateY(-50%);
    width: 44px;
    height: 24px;
    background: var(--border);
    border-radius: 12px;
    transition: all 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--text-primary);
    border-radius: 50%;
    transition: all 0.2s;
}

.toggle-setting input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle-setting input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* ========================================
   Mode Tabs
   ======================================== */

.mode-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.mode-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.813rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-tab:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.mode-tab.active {
    background: var(--bg-tertiary);
    border-color: var(--border);
    color: var(--text-primary);
}

.mode-tab svg {
    flex-shrink: 0;
}

/* ========================================
   Context Lake Mode
   ======================================== */

.lake-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.lake-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.lake-header-left h2 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.lake-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.entity-path {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: monospace;
}

.permission-badge {
    font-size: 0.65rem;
    color: var(--warning, #f59e0b);
    background: rgba(245, 158, 11, 0.1);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm, 4px);
    margin-left: 0.5rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary:disabled:hover {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.btn-secondary {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.813rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--accent);
}

/* Entity Tree */
.entity-tree-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.entity-type {
    margin-bottom: 0.25rem;
}

.entity-type-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.2s;
}

.entity-type-header:hover {
    background: var(--bg-tertiary);
}

.entity-type-name {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 500;
}

.entity-type-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
}

.entity-type-items {
    margin-left: 1rem;
    border-left: 1px solid var(--border);
    padding-left: 0.5rem;
}

.entity-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text-secondary);
}

.entity-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.entity-item.selected {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.entity-item-title {
    font-size: 0.813rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Entity Viewer */
.entity-viewer {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.entity-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.entity-frontmatter {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.frontmatter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.frontmatter-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.frontmatter-key {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.frontmatter-value {
    font-size: 0.875rem;
    color: var(--text-primary);
    word-break: break-word;
}

.entity-content-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.entity-rendered {
    line-height: 1.7;
}

.entity-rendered h1,
.entity-rendered h2,
.entity-rendered h3,
.entity-rendered h4,
.entity-rendered h5,
.entity-rendered h6 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
    line-height: 1.3;
}

.entity-rendered h1:first-child,
.entity-rendered h2:first-child,
.entity-rendered h3:first-child {
    margin-top: 0;
}

.entity-rendered p {
    margin-bottom: 1em;
}

.entity-rendered ul,
.entity-rendered ol {
    margin: 1em 0;
    padding-left: 2em;
}

.entity-rendered li {
    margin: 0.5em 0;
}

.entity-rendered code {
    background: var(--bg-tertiary);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.9em;
}

.entity-rendered pre {
    background: var(--bg-tertiary);
    padding: 1em;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 1em 0;
}

.entity-rendered pre code {
    background: none;
    padding: 0;
}

.entity-rendered blockquote {
    border-left: 3px solid var(--border);
    padding-left: 1em;
    margin: 1em 0;
    color: var(--text-secondary);
}

.entity-rendered a {
    color: var(--accent);
    text-decoration: none;
}

.entity-rendered a:hover {
    text-decoration: underline;
}

.entity-source {
    margin: 0;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-size: 0.813rem;
    line-height: 1.5;
}

.entity-source code {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    color: var(--text-secondary);
}

/* Workspace Select */
.workspace-select {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a8a8a8' stroke-width='2'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}

.workspace-select:hover {
    border-color: var(--accent);
}

.workspace-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 95;
        transition: left 0.3s;
    }

    .sidebar.open {
        left: 0;
    }

    .app-container {
        flex-direction: column;
    }

    .main-content {
        width: 100%;
    }

    .lake-header {
        flex-direction: column;
        gap: 0.75rem;
    }

    .lake-header-right {
        width: 100%;
        justify-content: flex-end;
    }
}

/* ========================================
   Entity Editor Styles
   ======================================== */

.entity-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-secondary);
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}

.editor-title {
    font-size: 1.25rem;
    font-weight: 500;
    margin: 0;
}

.editor-title-input {
    flex: 1;
    font-size: 1.25rem;
    font-weight: 500;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
}

.editor-title-input:focus {
    outline: none;
    border-color: var(--accent);
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dirty-indicator {
    color: var(--warning);
    font-size: 1.5rem;
    margin-right: 0.5rem;
}

.editor-error {
    padding: 0.75rem 1.5rem;
    background: rgba(239, 68, 68, 0.1);
    border-bottom: 1px solid var(--error);
    color: var(--error);
    font-size: 0.875rem;
}

.editor-frontmatter {
    padding: 1rem 1.5rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.frontmatter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.frontmatter-header span {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.frontmatter-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.frontmatter-field {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.frontmatter-field label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 60px;
}

.frontmatter-field input {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    width: 150px;
}

.frontmatter-field input:focus {
    outline: none;
    border-color: var(--accent);
}

.frontmatter-empty {
    color: var(--text-tertiary);
    font-size: 0.875rem;
    font-style: italic;
}

.editor-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-textarea {
    flex: 1;
    width: 100%;
    background: var(--bg-primary);
    border: none;
    color: var(--text-primary);
    padding: 1.5rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    resize: none;
}

.editor-textarea:focus {
    outline: none;
}

.editor-preview {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: var(--bg-primary);
}

/* Button Styles */

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--text-tertiary);
}

.btn-danger-outline {
    color: var(--error);
    border-color: var(--error);
}

.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.1);
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.btn-small:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-icon {
    padding: 0.25rem;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-icon.btn-danger:hover {
    color: var(--error);
}

.btn-create {
    opacity: 0;
    transition: opacity 0.2s;
    color: var(--accent);
}

.entity-type-header-row:hover .btn-create {
    opacity: 1;
}

.btn-create:hover {
    background: rgba(139, 43, 214, 0.1);
}

/* Entity Type Header Row */

.entity-type-header-row {
    display: flex;
    align-items: center;
    padding-right: 0.5rem;
}

.entity-type-header-row .entity-type-header {
    flex: 1;
}

/* Notification */

.notification {
    position: fixed;
    top: 1rem;
    right: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.notification.success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
}

.notification.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Modal Additions */

.modal-select {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
}

.modal-select:focus {
    outline: none;
    border-color: var(--accent);
}

.modal-body label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.checkbox-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent);
}

/* ========================================
   Claude Sidebar Styles
   ======================================== */

.lake-content-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.lake-content-wrapper .entity-viewer {
    flex: 1;
    overflow-y: auto;
}

.claude-sidebar {
    width: 360px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease, opacity 0.2s ease;
}

.claude-sidebar:not(.open) {
    width: 0;
    opacity: 0;
    overflow: hidden;
}

.claude-sidebar .sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.claude-sidebar .sidebar-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--accent);
}

.sidebar-context {
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    font-size: 0.8125rem;
}

.context-label {
    color: var(--text-tertiary);
    margin-right: 0.5rem;
}

.context-entity {
    color: var(--text-primary);
    font-weight: 500;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.quick-action-btn {
    padding: 0.375rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}

.quick-action-btn:hover:not(:disabled) {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--accent);
}

.quick-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sidebar-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sidebar-message {
    position: relative;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

.sidebar-message.user {
    background: var(--accent);
    color: white;
    margin-left: 2rem;
}

.sidebar-message.assistant {
    background: var(--bg-tertiary);
    margin-right: 2rem;
}

.sidebar-message .message-role {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    opacity: 0.7;
    margin-bottom: 0.375rem;
}

.sidebar-message .message-content {
    line-height: 1.5;
}

.sidebar-message .message-content p {
    margin: 0 0 0.5rem;
}

.sidebar-message .message-content p:last-child {
    margin-bottom: 0;
}

.sidebar-message .message-content pre {
    background: var(--bg-primary);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 0.8125rem;
    margin: 0.5rem 0;
}

.sidebar-message .message-content code {
    font-size: 0.8125rem;
}

.sidebar-message .message-content ul,
.sidebar-message .message-content ol {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.sidebar-message.streaming .message-content::after {
    content: '|';
    animation: blink 1s infinite;
}

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

.sidebar-message .message-content.typing {
    color: var(--text-secondary);
    font-style: italic;
}

.btn-copy {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}

.sidebar-message:hover .btn-copy {
    opacity: 1;
}

.btn-copy:hover {
    color: var(--text-primary);
}

.sidebar-input {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.sidebar-input textarea {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    resize: none;
    font-family: inherit;
}

.sidebar-input textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-send {
    padding: 0.5rem 0.75rem;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-send:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sidebar-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

/* Active state for Claude button */
.btn-secondary.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn-secondary.active:hover {
    background: var(--accent-hover);
}

/* Expanded sidebar */
.claude-sidebar.expanded {
    width: calc(100% - 280px);
}

/* Sidebar header actions */
.sidebar-header-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Attachments section */
.sidebar-attachments {
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
}

.attachments-label {
    color: var(--text-tertiary);
    font-size: 0.75rem;
}

.attachments-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.25rem 0.5rem 0.25rem 0.625rem;
    font-size: 0.75rem;
}

.attachment-title {
    color: var(--text-secondary);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-remove {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attachment-remove:hover {
    color: var(--error);
}

.attachment-add {
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: 999px;
    padding: 0.25rem 0.5rem;
    color: var(--text-tertiary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}

.attachment-add:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Tool messages in sidebar */
.sidebar-message.tool {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    margin: 0 1rem;
    font-size: 0.8125rem;
}

.sidebar-message.tool .message-role {
    color: var(--warning);
}

.sidebar-message.tool .tool-input {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.75rem;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 100px;
    overflow-y: auto;
    color: var(--text-secondary);
}

/* Selection context in sidebar */
.sidebar-selection {
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.selection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.selection-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.selection-clear {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0;
}

.selection-clear:hover {
    text-decoration: underline;
}

.selection-quote {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.4;
    padding-left: 0.75rem;
    border-left: 2px solid var(--accent);
}

/* Selection Toolbar (floating) */
.selection-toolbar {
    position: absolute;
    transform: translateX(-50%);
    display: flex;
    gap: 2px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;
    animation: fadeInUp 0.15s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.selection-action {
    padding: 0.375rem 0.625rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

.selection-action:hover {
    background: var(--accent);
    color: white;
}

/* Entity viewer needs relative positioning for toolbar */
.entity-viewer {
    position: relative;
}

/* Responsive */
@media (max-width: 900px) {
    .claude-sidebar {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
    }

    .claude-sidebar:not(.open) {
        right: -360px;
        width: 360px;
    }
}
