/* Sanzen Roshi - Minimal Zen Interface */

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2a2a2a;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-muted: #606060;
    --accent: #4a90e2;
    --accent-hover: #357abd;
    --success: #52c41a;
    --error:   #ff6b6b;
    --warning: #faad14;
    --info:    var(--accent, #58a6ff);
    --toast-radius: 12px;
    --border: #333;
    --shadow: rgba(0, 0, 0, 0.5);
    --msg-font: inherit;
    --msg-size: 16px;
    --msg-height: 1.5;
    --msg-gap: 0.5rem;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

/* Header */
#mainHeader {
    background: var(--bg-secondary);
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

#mainHeader nav {
    display: flex;
    justify-content: space-between;
}

#mainHeader ul {
    list-style: none;
    display: flex;
    gap: 1.5rem;
}

#mainHeader a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

#mainHeader a:hover {
    color: var(--text-primary);
}

/* Main Terminal */
#terminal {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding-top: 3.5rem;
    overflow: hidden;
}

.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* Output Area */


#output {
    flex: 1;
    overflow-y: auto; /* This enables vertical scrollbar */
    overflow-x: hidden; /* Prevent horizontal scroll */
    padding: 1rem;
    background: var(--bg-primary);
    min-height: 0; /* Critical for flexbox */
    max-height: 100%; /* Ensure it doesn't exceed parent */
}

/* Ensure all messages are visible by default */
.message {
    display: block;  /* Add this */
    margin-top: var(--msg-gap);
    font-family: var(--msg-font);
    font-size: var(--msg-size);
    line-height: var(--msg-height);
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.message .content {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message .content pre {
    overflow-x: auto;
    max-width: 100%;
}

.message.user {
    color: var(--accent);
}

.message.remote-user {
    color: var(--text-secondary);
}

.message.ai {
    color: var(--text-primary);
}

.message .timestamp {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.message .author {
    font-weight: bold;
    margin: 0 0.5rem;
}

/* Input Container */
.input-container {
    flex-shrink: 0; /* Don't let it shrink */
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 1rem;
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

.input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.5rem 1rem;
}

#inputLine {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
}

.input-right-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#tokenCounter {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-family: monospace;
}

/* Buttons */
button {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

button:hover {
    background: var(--bg-secondary);
    border-color: var(--accent);
}

.toggle-artifacts-button,
.settings-button {
    background: none;
    border: none;
    padding: 0.5rem;
    color: var(--text-secondary);
}

.toggle-artifacts-button:hover,
.settings-button:hover {
    color: var(--text-primary);
}

/* Power level buttons - compact for preferences */
.power-btn {
    padding: 0.3rem 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    font-family: monospace;
    font-weight: 600;
    font-size: 0.85em;
    border-radius: 3px;
    transition: all 0.2s;
}

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

.power-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Persona buttons - compact for preferences */
.persona-btn {
    padding: 0.4rem 0.7rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 0.85em;
    white-space: nowrap;
}

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

.persona-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Preference section styling */
.preference-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.preference-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.preference-item {
    margin-bottom: 1rem;
}

.preference-item label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9em;
}


/* Panels */

.preferences-panel,
.conversations-panel {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    overflow-y: auto;
    z-index: 90;
    transition: transform 0.3s ease;
    top: 3.5rem;
    bottom: 4.5rem;
}

/* Conversations panel - slides from left */
.conversations-panel {
    left: 0;
    width: 40%;  /* 40% of screen width */
    transform: translateX(-100%);  /* Hidden by default */
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.conversations-panel:not(.collapsed) {
    transform: translateX(0);  /* Visible state */
}

/* Add these styles to your existing CSS */

/* When conversation is active, invert button colors */
.conversation-item.active .conversation-actions button {
    color: white;
    opacity: 0.8;
}

.conversation-item.active .conversation-actions button:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
}

.conversation-item.active .conversation-actions button svg {
    stroke: white;
}

/* Special handling for delete button in active state */
.conversation-item.active .conversation-delete:hover {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

/* Alternative approach with better contrast */
.conversation-item.active .conversation-delete:hover {
    background: var(--error);
    color: white;
    opacity: 1;
}

/* For better visibility, you might want to adjust the active conversation background */
.conversation-item.active {
    background: var(--accent);
    color: white;
    /* Add a subtle shadow for depth */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Ensure all text in active conversation is white */
.conversation-item.active .conversation-title,
.conversation-item.active .conversation-meta {
    color: white;
}

.conversation-item.active .conversation-meta {
    color: rgba(255, 255, 255, 0.9);
}



/* Preferences panel - slides from right */
.preferences-panel {
    right: 0;
    width: 40%;  /* 40% of screen width */
    transform: translateX(100%);  /* Hidden by default */
    padding: 1.5rem;
}

.preferences-panel.show {
    transform: translateX(0);  /* Visible state */
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .preferences-panel,
    .conversations-panel {
        width: 85%;  /* Most of screen on mobile */
    }
}

/* Tablet/medium screens */
@media (min-width: 769px) and (max-width: 1200px) {
    .preferences-panel,
    .conversations-panel {
        width: 50%;  /* Half screen on tablets */
    }
}

/* Optional: Set max-width for very large screens */
@media (min-width: 1600px) {
    .preferences-panel,
    .conversations-panel {
        max-width: 700px;  /* Cap width on huge monitors */
    }
}

.conversation-context {
    flex: 1;                 /* Add this */
    display: flex;           /* Add this */
    flex-direction: column;  /* Add this */
    padding: 1rem;
    min-height: 0;          /* Important for Firefox */
}

.context-heading {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.context-field {
    flex: 1;
    width: 100%;
    resize: none;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.75rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
}

/* Add these styles for the context panel controls */
.context-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.context-controls .btn-bevel {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
}

.context-controls .btn-bevel svg {
    width: 16px;
    height: 16px;
}

.context-field {
    min-height: 200px;
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
}

.context-field::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

#clearContextBtn:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .context-controls {
        flex-wrap: wrap;
    }
    
    .context-controls .btn-bevel {
        flex: 1;
        min-width: 120px;
        justify-content: center;
    }
}



/* Preferences Sections */
.preferences-section {
    margin-bottom: 2rem;
}

.preferences-section-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* TAL Info Display */
.tal-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.balance-label,
.sequence-label,
.expires-label {
    font-family: monospace;
    color: var(--text-primary);
}

.balance-label {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--success);
}

/* Token Buttons */
.token-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.btn-dollar {
    background: var(--bg-tertiary);
    border: 1px solid var(--success);
    color: var(--success);
    padding: 0.75rem;
    font-weight: 500;
}

.btn-dollar:hover {
    background: var(--success);
    color: var(--bg-primary);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-close:hover {
    color: var(--text-primary);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.submit-button {
    background: var(--accent);
    color: white;
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
}

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


/* ===========================
   Pro Toast 
   =========================== */

/* Optional stack container (recommended for multiple toasts) */
.toast-stack {
  position: fixed;
  right: 1.25rem;
  bottom: 5.5rem; /* clear input line */
  display: flex;
  flex-direction: column;
  gap: .6rem;
  z-index: 2600;
  pointer-events: none; /* toasts inside remain clickable */
}
.toast-stack .toast { position: relative; inset: auto; }

/* Base toast */
.toast {
  /* Position works alone (no stack) */
  position: fixed;
  right: 1.25rem;
  bottom: 5.5rem;

  z-index: 2600;
  pointer-events: auto;

  /* Layout */
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: start;
  column-gap: .75rem;

  min-width: 260px;
  max-width: clamp(240px, 50vw, 420px);
  padding: .75rem .9rem;
  border-radius: var(--toast-radius);

  /* Theme-aware surfaces */
  --toast-accent: var(--info);
  --toast-bg:     color-mix(in oklab, var(--bg-secondary, #202327) 88%, transparent);
  --toast-text:   var(--text-primary, #e6e6e6);
  --toast-muted:  var(--text-secondary, #aeb3b9);
  --toast-border: var(--border, #2f3336);

  color: var(--toast-text);
  background-color: var(--toast-bg);
  border: 1px solid var(--toast-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);

  /* Soft depth that survives your global box-shadow reset */
  filter: drop-shadow(0 10px 28px rgba(0,0,0,.28)) drop-shadow(0 2px 8px rgba(0,0,0,.18));

  /* Accent stripe + subtle tint overlay */
  background-image:
    linear-gradient(to right, var(--toast-accent) 3px, transparent 3px),
    linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,0)); /* fallback */
  background-clip: padding-box, border-box;
}
@supports (background: color-mix(in oklab, red, blue)) {
  .toast {
    background-image:
      linear-gradient(to right, var(--toast-accent) 3px, transparent 3px),
      linear-gradient(180deg, color-mix(in oklab, var(--toast-accent) 12%, transparent), transparent);
  }
}

/* Motion & entrance */
.toast {
  transform: translateY(12px) translateZ(0);
  opacity: 0;
  will-change: transform, opacity;
  transition: transform .28s ease, opacity .2s ease, background-color .2s ease, border-color .2s ease;
}
.toast.show { transform: translateY(0) translateZ(0); opacity: 1; }
.toast:hover { filter: drop-shadow(0 12px 34px rgba(0,0,0,.32)) drop-shadow(0 3px 10px rgba(0,0,0,.2)); }

/* Icon pill (no markup required) */
.toast::before {
  content: '';
  grid-column: 1;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--toast-accent);
  color: #fff; /* glyph color inside the pill */
  font: 700 14px/1 ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
}

/* Use friendly glyphs per type (no SVG needed) */
.toast-success::before { content: '✓'; }
.toast-error::before   { content: '⨯'; }
.toast-info::before    { content: 'i'; }
.toast-warning::before { content: '!'; }

/* Title + message (work whether you have them or just text) */
.toast .toast-title {
  grid-column: 2;
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 .15rem 0;
}
.toast .toast-message {
  grid-column: 2;
  line-height: 1.35;
  color: var(--toast-muted);
}

/* Optional close button (if present in markup) */
.toast .toast-close {
  grid-column: 3;
  margin-left: .5rem;
  background: transparent;
  border: 0;
  color: var(--text-secondary, #aeb3b9);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
}
.toast .toast-close:hover { background: var(--bg-tertiary, rgba(255,255,255,.06)); color: var(--text-primary, #fff); }

/* Variants set the accent without recoloring body text */
.toast-success { --toast-accent: var(--success); }
.toast-error   { --toast-accent: var(--error); }
.toast-info    { --toast-accent: var(--info); }
.toast-warning { --toast-accent: var(--warning); }

/* Optional: progress bar countdown (no extra markup—toggle via data-progress) */
.toast[data-progress]::after {
  content: '';
  position: absolute;
  left: 3px;              /* clear the accent stripe */
  right: 8px;
  bottom: 6px;
  height: 2px;
  border-radius: 2px;
  background: var(--toast-accent);
  transform-origin: left;
  animation: toast-progress var(--toast-duration, 4s) linear forwards;
  opacity: .9;
}
@keyframes toast-progress {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; transform: none; opacity: 1; }
  .toast[data-progress]::after { animation: none; width: 0; }
}



/* Provider Chips */
.provider-chips {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.provider-chip {
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.provider-chip:hover {
    border-color: var(--accent);
}

.provider-chip.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}


/* Fix the conversations panel to fit properly between header and input */

.artifact-quick-view#conversationsPanel {
    position: fixed;
    right: -400px;
    top: 3.5rem; /* Height of the header */
    bottom: 4rem; /* Height of input container */
    width: 400px;
    max-width: 90%;
    background: var(--bg-primary);
    border-left: 1px solid var(--border);
    transition: right 0.3s ease;
    z-index: 90;
    display: flex;
    flex-direction: column;
    padding: 0;
}

/* Adjust for safe areas on mobile */
@supports (top: env(safe-area-inset-top)) {
    .artifact-quick-view#conversationsPanel {
        top: calc(3.5rem + env(safe-area-inset-top));
        bottom: calc(4rem + env(safe-area-inset-bottom));
    }
}

/* The header section should have its own padding */
.artifact-quick-view#conversationsPanel .artifact-quick-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
    /* Ensure header doesn't scroll with content */
    flex-shrink: 0;
}

/* Content area fills remaining space */
.artifact-quick-view#conversationsPanel .artifact-quick-content,
.artifact-quick-view#conversationsPanel #sessionsList {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    -webkit-overflow-scrolling: touch;
    min-height: 0; /* Important for Firefox */
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .artifact-quick-view#conversationsPanel {
        width: 100%;
        max-width: 100%;
        right: -100%;
        /* Adjust positioning for mobile header/input sizes */
        top: 3.5rem;
        bottom: 5rem; /* Mobile input is often taller */
    }
}

/* Landscape mobile adjustments */
@media (orientation: landscape) and (max-height: 500px) {
    .artifact-quick-view#conversationsPanel {
        top: 3rem; /* Smaller header in landscape */
        bottom: 3.5rem; /* Smaller input area */
    }
}

/* Ensure visible state works correctly */
.artifact-quick-view#conversationsPanel.visible {
    right: 0;
}

/* Fix z-index stacking */
#mainHeader {
    z-index: 100; /* Header stays on top */
}

.input-container {
    z-index: 95; /* Input above panel */
}

.artifact-quick-view#conversationsPanel {
    z-index: 90; /* Panel below both */
}



/* Artifact Quick View */
.artifact-quick-view {
    position: fixed;
    right: -400px;
    top: 3.5rem;
    bottom: 4rem;
    width: 400px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    transition: right 0.3s ease;
    z-index: 80;
}

.artifact-quick-view.visible {
    right: 0;
}

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

.artifact-quick-content {
    padding: 1rem;
    overflow-y: auto;
    height: calc(100% - 60px);
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .preferences-panel {
        width: 100%;
        right: -100%;
    }
    
    .preferences-panel.show {
        transform: translateX(-100%);
    }
    
    .conversations-panel {
        width: 85%;
    }
    
    .token-buttons {
        grid-template-columns: 1fr;
    }
}

/* Tutorial Modal Styles */
.tutorial-content {
    max-width: 600px;
    position: relative;
}

.tutorial-steps {
    min-height: 300px;
    position: relative;
    margin: 2rem 0;
}

.tutorial-step {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tutorial-step.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tutorial-step h3 {
    color: var(--accent);
    margin-bottom: 1rem;
}

.tutorial-step ul {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.tutorial-step li {
    margin: 0.5rem 0;
    line-height: 1.6;
}

.tutorial-tip {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--accent);
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    font-style: italic;
}

.command-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin: 1rem 0;
    max-height: 200px;
    overflow-y: auto;
}

.command-grid code {
    background: var(--bg-tertiary);
    padding: 0.5rem;
    border-radius: 4px;
    display: block;
    font-size: 0.85rem;
    white-space: nowrap;
}

.tutorial-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.tutorial-nav-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.tutorial-nav-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

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

.tutorial-dots {
    display: flex;
    gap: 0.5rem;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.dot.active {
    background: var(--accent);
    transform: scale(1.2);
}

.dot:hover {
    background: var(--text-secondary);
}

/* Alternative: Add text shadow for readability without backgrounds */
body[class*="room-"] .message {
    background: rgba(10, 10, 10, 0.0) !important;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.8), 
                 0 0 8px rgba(0, 0, 0, 0.6),
                 0 0 12px rgba(0, 0, 0, 0.4);
    padding: 0.25rem 0.5rem;
}


/* Chat bubble mode styles */
body.chat-mode #output {
    gap: var(--msg-gap);
    padding: 1.5rem;
}

body.chat-mode .message {
    display: flex;
    flex-direction: column;  /* ADD THIS LINE */
    margin-bottom: 1rem;
    font-family: var(--msg-font);
    font-size: var(--msg-size);
    line-height: var(--msg-height);
    width: 100%;
}

body.chat-mode .message.user {
    align-items: flex-end;
}

body.chat-mode .message.ai {
    align-items: flex-start;
}

/* Add border to user bubbles */
body.chat-mode .message.user .content {
    background: var(--accent);
    color: white;
    border: 1px solid var(--accent);  /* Add border in same color */
    border-bottom-right-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);  /* Optional: subtle shadow for depth */
}


/* Hide IRC-style elements in chat mode */
body.chat-mode .message .timestamp,
body.chat-mode .message .author {
    display: none;
}

/* Chat bubble styling */
body.chat-mode .message .content {
    background: var(--bg-tertiary);
    padding: 0.75rem 1rem;
    border-radius: 18px;
    max-width: 70%;
    position: relative;
    word-wrap: break-word;
}

body.chat-mode .message.user .content {
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}

body.chat-mode .message.ai .content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

/* Chat bubble mode - fix remote user display */
body.chat-mode .message.remote-user {
    display: flex;  /* Ensure it's displayed */
    flex-direction: column;
    align-items: flex-start;  /* Align like AI messages */
    margin-bottom: 1rem;
}

/* Show author for remote users in chat mode */
body.chat-mode .message.remote-user .author {
    display: block !important;  /* Override the hide rule */
    font-size: 0.75rem;
    opacity: 0.7;
    margin-bottom: 0.25rem;
    margin-left: 0.75rem;
    color: var(--text-secondary);
}

/* Style remote user content bubbles */
body.chat-mode .message.remote-user .content {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    padding: 0.75rem 1rem;
    border-radius: 18px;
    max-width: 70%;
}


/* Time indicators on hover */
body.chat-mode .message .content::after {
    content: attr(data-time);
    position: absolute;
    bottom: -20px;
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s;
    white-space: nowrap;
}

body.chat-mode .message.user .content::after {
    right: 0;
}

body.chat-mode .message.ai .content::after {
    left: 0;
}

body.chat-mode .message:hover .content::after {
    opacity: 1;
}

/* System messages in chat mode */
body.chat-mode .message.system {
    justify-content: center;
    margin: 1.5rem 0;
}

body.chat-mode .message.system .content {
    background: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    max-width: none;
    padding: 0.5rem;
    border: none;
}

/* Toggle button styling */
.view-toggle-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.view-toggle-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}

.view-toggle-btn.active {
    color: var(--accent);
    border-color: var(--accent);
}

.form-note {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.75rem;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.last-email {
    margin-top: 1rem;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 0.9rem;
    text-align: center;
}

#encryptPassword, #decryptPassword {
    width: 100%;
    padding: 0.75rem;
    margin-top: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 1rem;
}

#encryptPassword:focus, #decryptPassword:focus {
    outline: none;
    border-color: var(--accent);
}

.modal-footer .btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.modal-footer .btn-secondary:hover {
    background: var(--bg-secondary);
}

body.custom-background {
    /* The background-image will be set inline by JavaScript */
    background-size: cover !important;
    background-position: center !important;
    background-attachment: fixed !important;
    background-repeat: no-repeat !important;
}

/* Make containers transparent when custom background is active */
body.custom-background #terminal {
    background: rgba(0, 0, 0, 0) !important;  /* Much more transparent */
}

body.custom-background .chat-panel {
    background: rgba(0, 0, 0, 0) !important;
}

body.custom-background #output {
    background: rgba(0, 0, 0, 0) !important;
}

body.custom-background .input-container {
    background: rgba(26, 26, 26, 0.9) !important;
}

body.custom-background .preferences-panel,
body.custom-background .conversations-panel {
    background: rgba(26, 26, 26, 0.92) !important;
    backdrop-filter: blur(5px);
}

body.custom-background .modal-content {
    background: rgba(26, 26, 26, 0.95) !important;
}

/* Adjust message styling for better readability */
body.custom-background .message {
    background: rgba(0, 0, 0, 0) !important;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.preference-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

.preference-info code {
    background: var(--bg-tertiary);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.85em;
    color: var(--text-primary);
}

.conversation-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    width: 30px;
    height: 30px;
    padding: 0;
    margin-left: 0.5rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.conversation-delete svg {
    width: 14px;
    height: 14px;
    opacity: 0.6;
    transition: all 0.2s ease;
}

.conversation-delete:hover {
    background: var(--error);
    color: white;
}

.conversation-delete:hover svg {
    opacity: 1;
    transform: scale(1.1);
}

.session-buttons {
    display: flex;
    gap: 0.5rem;
}

.new-conversation-btn,
.export-all-btn,
.import-conversation-btn {
    color: var(--bg-tertiary);
    background: var(--accent);
    border: 1px solid var(--accent);
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.new-conversation-btn:hover,
.export-all-btn:hover,
.import-conversation-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.conversation-actions {
    display: flex;
    gap: 0.25rem;
}

.conversation-item:hover .conversation-actions {
    opacity: 1;
}

.conversation-rename,
.conversation-export,
.conversation-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.conversation-rename:hover,
.conversation-export:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.conversation-delete:hover {
    background: var(--error);
    color: white;
}

.conversation-rename svg,
.conversation-export svg,
.conversation-delete svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;  /* Ensures SVG uses button's text color */
    fill: none;    
}

.conversation-item.active {
    background: var(--accent);
    color: white;
}

.conversation-item.active .conversation-meta {
    color: rgba(255, 255, 255, 0.8);
}


.favorite-personas-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-top: 1rem;
}

.favorite-persona-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    height: 110px;
    position: relative;
    box-sizing: border-box;
}

.favorite-persona-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.favorite-persona-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.favorite-persona-btn.active svg {
    stroke: white;
    fill: white;
}

.favorite-persona-btn.edit-mode {
    border: 2px dashed var(--accent);
}

.favorite-persona-btn.edit-mode::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.persona-icon-wrapper {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.persona-icon-wrapper svg {
    width: 36px;
    height: 36px;
    stroke: var(--text-primary);
    fill: none;
    transition: all 0.2s;
}

.persona-name {
    font-size: 0.85rem;
    text-align: center;
    font-weight: 500;
    word-break: break-word;
    line-height: 1.2;
    max-width: 100%;
    flex-shrink: 0;
    height: 2.4em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-personas-btn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 0.25rem;
    margin-left: 0.5rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}



.edit-personas-btn:hover {
    opacity: 1;
}

.edit-mode-instructions {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 4px;
    text-align: center;
}

.edit-mode-instructions p {
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.quick-persona-input {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.quick-persona-input input {
    flex: 1;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
}

.persona-suggestions {
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.suggestion-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.suggestion-chip {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    padding: 0.25rem 0.75rem;
    border-radius: 16px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-chip:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Icon Picker in Modal */
.persona-edit-content {
    max-width: 500px;
    width: 90%;
}

.icon-picker {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.icon-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 0.75rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: var(--bg-primary);
    transform: scale(1.1);
}

.icon-btn.selected {
    background: var(--accent);
    border-color: var(--accent);
}

.icon-btn svg {
    width: 24px;
    height: 24px;
    stroke: var(--text-primary);
    fill: none;
}

.icon-btn.selected svg {
    stroke: white;
}

.selected-icon-preview {
    margin-top: 1rem;
    font-size: 1rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.selected-icon-preview svg {
    width: 24px;
    height: 24px;
}

/* Mobile optimization */
@media (max-width: 768px) {
    .favorite-personas-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .favorite-persona-btn {
        height: 95px;
        padding: 0.75rem;
    }

    .persona-icon-wrapper {
        width: 36px;
        height: 36px;
    }

    .persona-icon-wrapper svg {
        width: 32px;
        height: 32px;
    }

    .icon-picker {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Add to your existing CSS */
.message .author.colored {
    font-weight: bold;
    text-shadow: 0 0 1px rgba(0,0,0,0.3);
}

/* Chat bubble mode - colored author labels */
body.chat-mode .message.remote-user .author,
body.chat-mode .message.user .author {
    font-weight: bold;
    opacity: 1;
}

/* Typing indicator with user color */
.typing-indicator.colored {
    border-left: 3px solid var(--user-color);
}

/* Custom model indicator */
.custom-model-indicator {
    position: fixed;
    top: 3.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.custom-model-label {
    opacity: 0.8;
}

.custom-model-name {
    font-family: monospace;
    font-weight: bold;
}

.clear-custom-model {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.7;
    padding: 0 0.25rem;
    transition: opacity 0.2s;
}

.clear-custom-model:hover {
    opacity: 1;
}

/* Custom models grid */
.custom-models-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.5rem;
    margin: 1rem 0;
}

.custom-model-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    text-align: center;
}

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

.model-provider {
    font-size: 0.75rem;
    opacity: 0.7;
    text-transform: uppercase;
}

.model-name {
    font-size: 0.85rem;
    font-weight: 500;
}

/* Custom model input */
.custom-model-input {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.custom-model-input input {
    flex: 1;
}

.custom-model-input select {
    width: 120px;
}

/* Adjust power buttons when in custom model mode */
.custom-model-mode .power-btn {
    opacity: 0.5;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .custom-model-indicator {
        top: auto;
        bottom: 5.5rem;
        font-size: 0.75rem;
        padding: 0.4rem 0.8rem;
    }
    
    .custom-models-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Room backgrounds - add !important to override theme backgrounds */
body.room-garden { background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.1)), url('garden.jpg') center/cover fixed !important; }
body.room-coffeeshop { background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.1)), url('coffeeshop.jpg') center/cover fixed !important; }
body.room-library { background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.1)), url('library.jpg') center/cover fixed !important; }
body.room-workshop { background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.1)), url('workshop.jpg') center/cover fixed !important; }
body.room-meditation { background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.1)), url('meditation.jpg') center/cover fixed !important; }
body.room-marketplace { background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.1)), url('marketplace.jpg') center/cover fixed !important; }
body.room-observatory { background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.1)), url('observatory.jpg') center/cover fixed !important; }
body.room-kitchen { background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.1)), url('kitchen.jpg') center/cover fixed !important; }
body.room-dreamscape { background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.1)), url('reamscape.jpg') center/cover fixed !important; }
body.room-lobby { background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.1)), url('lobby.jpg') center/cover fixed !important; }

/* Make containers semi-transparent when in a room */
body[class*="room-"] #terminal,
body[class*="room-"] #output {
    background: transparent !important;
}

body[class*="room-"] .input-container {
    background: rgba(26, 26, 26, 0.35) !important;
/*    backdrop-filter: blur(10px); */
}

/* Ensure text remains readable */
body[class*="room-"] .message.user {
    color: #6bb6ff;
}

body[class*="room-"] .message.ai {
    color: #ffffff;
}

/* Power buttons disabled state when in custom model mode */
.custom-model-mode .power-btn {
    opacity: 0.4;
    cursor: not-allowed;
}

.custom-model-mode .power-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border);
}

/* Auto-highlight active model/power buttons */
body.custom-model-mode .power-btn {
    opacity: 0.5;
    pointer-events: none;
}

.model-btn[data-model] {
    position: relative;
}

/* This will be controlled by a data attribute on body */
body[data-active-model] .model-btn {
    opacity: 0.5;
}

body[data-active-model] .model-btn.active-model {
    opacity: 1;
    background: var(--accent);
    color: white;
}

/* Auto-highlight active custom model button */
.custom-model-btn[data-provider][data-model] {
    position: relative;
}

/* Highlight when data attributes match body attributes */
body[data-active-model] .custom-model-btn {
    opacity: 0.7;
}

body[data-active-provider][data-active-model] .custom-model-btn[data-provider][data-model] {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    opacity: 1;
}

/* Simple active state for custom model buttons */
.custom-model-btn {
    transition: all 0.2s;
}

.custom-model-btn.active {
    background: var(--accent) !important;
    color: white !important;
    border-color: var(--accent) !important;
    box-shadow: 0 0 10px rgba(106, 159, 181, 0.3);
}

/* Room indicator in input area */
.room-indicator {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 4px 0 0 4px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.room-id-label {
    font-family: monospace;
    font-weight: bold;
    color: var(--accent);
    font-size: 0.9rem;
}

/* Adjust input when room indicator is present */
.multi-user-mode .input-area {
    display: flex;
    align-items: stretch;
}

.multi-user-mode #inputLine {
    border-radius: 0 4px 4px 0;
    flex: 1;
}
