/* Ragsmith Web UI Styles */

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

html {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a2e;
    color: #eee;
    height: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@supports (-webkit-touch-callout: none) {
    body { height: -webkit-fill-available; }
}

/* ============================================================================
   Header
   ============================================================================ */
header {
    padding: 0.75rem 1rem;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 1;
}

header h1 {
    font-size: 1.25rem;
    color: #e94560;
    flex-shrink: 0;
}

.header-status {
    font-size: 0.85rem;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mode-indicator {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    flex-shrink: 0;
}

.mode-indicator.teacher { background: #7c3aed; color: #fff; }
.mode-indicator.model { background: #0369a1; color: #fff; }

/* ============================================================================
   Hamburger Menu Button
   ============================================================================ */
.hamburger {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.hamburger:hover {
    background: rgba(233, 69, 96, 0.2);
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: #e94560;
    border-radius: 1px;
    transition: transform 0.2s, opacity 0.2s;
}

/* ============================================================================
   Menu Overlay
   ============================================================================ */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================================================
   Slide-out Menu Panel
   ============================================================================ */
.menu-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 360px;
    max-width: 85vw;
    height: 100%;
    background: #16213e;
    border-left: 1px solid #0f3460;
    z-index: 300;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.menu-panel.open {
    transform: translateX(0);
}

.menu-header {
    padding: 1rem;
    border-bottom: 1px solid #0f3460;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.menu-header h2 {
    font-size: 1.1rem;
    color: #e94560;
}

.menu-close {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: #888;
    font-size: 1.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
    line-height: 1;
}

.menu-close:hover {
    background: rgba(233, 69, 96, 0.2);
    color: #e94560;
}

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

.menu-section {
    margin-bottom: 1rem;
}

.menu-section label {
    display: block;
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.menu-section select {
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: #0f3460;
    color: #eee;
    border: 1px solid #333;
    border-radius: 4px;
    font-size: 0.95rem;
    cursor: pointer;
    margin-bottom: 0.75rem;
}

.menu-section select:focus {
    outline: none;
    border-color: #e94560;
}

/* Context selectors (Agent & Collection side-by-side) */
.menu-row {
    margin-bottom: 1rem;
}

.context-selectors {
    display: flex;
    gap: 12px;
}

.selector-group {
    flex: 1;
    min-width: 0; /* Allow shrinking */
}

.selector-group label {
    display: block;
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.selector-btn {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 0.75rem;
    background: #0f3460;
    color: #eee;
    border: 1px solid #333;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    text-align: left;
}

.selector-btn:hover {
    border-color: #555;
}

.selector-btn:focus {
    outline: none;
    border-color: #e94560;
}

.selector-btn span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.selector-arrow {
    color: #888;
    font-size: 0.75rem;
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.selector-btn.has-selection {
    border-color: #10b981;
}

.selector-btn.has-selection span:first-child {
    color: #10b981;
}

/* Temperature slider */
.slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #0f3460;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #e94560;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #e94560;
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

.slider-value {
    color: #e94560;
    font-weight: bold;
    margin-left: 0.5rem;
}

.info-tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    margin-left: 0.4rem;
    font-size: 0.65rem;
    font-weight: bold;
    color: #666;
    background: #333;
    border-radius: 50%;
    cursor: help;
    vertical-align: middle;
    position: relative;
}

.info-tooltip:hover {
    color: #e94560;
    background: #444;
}

/* Custom tooltip styling (uses data-tooltip to avoid browser native tooltip) */
.info-tooltip[data-tooltip] {
    position: relative;
}

.info-tooltip[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    margin-top: 6px;
    padding: 8px 10px;
    width: 200px;
    font-size: 0.75rem;
    font-weight: normal;
    text-transform: none;
    color: #eee;
    background: #1a1a2e;
    border: 1px solid #333;
    border-radius: 6px;
    white-space: normal;
    line-height: 1.4;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.info-tooltip[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    margin-top: 2px;
    border: 4px solid transparent;
    border-bottom-color: #333;
    z-index: 1001;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: #666;
    margin-top: 0.25rem;
}

.menu-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    background: #0f3460;
    color: #eee;
    border: 1px solid #333;
    border-radius: 4px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.menu-btn:hover:not(:disabled) {
    background: #1a4a7a;
    border-color: #e94560;
}

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

.menu-btn.primary {
    background: #e94560;
    border-color: #e94560;
    color: #fff;
}

.menu-btn.primary:hover:not(:disabled) {
    background: #d63a54;
}

/* Current Model Display */
.current-model-display {
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: #0f3460;
    color: #eee;
    border: 1px solid #333;
    border-radius: 4px;
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.current-model-display .model-icon {
    width: 20px;
    height: 20px;
    color: #e94560;
    flex-shrink: 0;
}

.current-model-display .model-icon svg {
    width: 100%;
    height: 100%;
}

.current-model-display .model-name-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.current-model-display.loaded {
    border-color: #10b981;
}

.current-model-display.loaded .model-icon {
    color: #10b981;
}

.menu-divider {
    height: 1px;
    background: #0f3460;
    margin: 1.25rem 0;
}

.menu-footer {
    padding: 1rem;
    border-top: 1px solid #0f3460;
}

.menu-footer #status {
    font-size: 0.8rem;
    color: #888;
}

.menu-footer #status.online { color: #4ade80; }
.menu-footer #status.offline { color: #f87171; }

/* ============================================================================
   Chat Container
   ============================================================================ */
#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

/* ============================================================================
   Messages
   ============================================================================ */
.message {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    line-height: 1.5;
    word-wrap: break-word;
    margin-bottom: 0.5rem;
}

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

.message.user {
    align-self: flex-end;
    background: #0f3460;
    border: 1px solid #e94560;
}

.message.assistant {
    align-self: flex-start;
    background: #16213e;
    border: 1px solid #0f3460;
}

.message.system {
    align-self: center;
    background: transparent;
    color: #888;
    font-size: 0.85rem;
    font-style: italic;
}

.message.command {
    align-self: flex-start;
    background: #1e3a5f;
    border: 1px solid #3b82f6;
    font-family: monospace;
    font-size: 0.9rem;
    white-space: pre-wrap;
}

/* Thinking section for reasoning models */
.thinking-section {
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 8px;
    font-size: 0.85rem;
}

.thinking-section summary {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: #a78bfa;
    font-weight: 500;
    user-select: none;
    list-style: none;
}

.thinking-section summary::-webkit-details-marker {
    display: none;
}

.thinking-section summary::before {
    content: '▶';
    font-size: 0.65rem;
    transition: transform 0.2s;
}

.thinking-section[open] summary::before {
    transform: rotate(90deg);
}

.thinking-section .thinking-icon {
    font-size: 0.9rem;
}

.thinking-section .thinking-content {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(139, 92, 246, 0.2);
    color: #c4b5fd;
    line-height: 1.5;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
}

/* Collection header - shown at top of collection conversations */
.collection-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.15) 0%, rgba(37, 99, 235, 0.05) 100%);
    border: 1px solid rgba(37, 99, 235, 0.3);
    border-radius: 12px;
    border-left: 4px solid #2563eb;
}

.collection-header-icon {
    font-size: 1.5rem;
    line-height: 1;
    margin-top: 0.1rem;
}

.collection-header-content {
    flex: 1;
    min-width: 0;
}

.collection-header-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #60a5fa;
    margin-bottom: 0.35rem;
}

.collection-header-description {
    font-size: 0.9rem;
    color: #94a3b8;
    line-height: 1.5;
}

.message .meta {
    font-size: 0.75rem;
    color: #666;
    margin-top: 0.5rem;
}

/* Message header (agent/user name) */
.message-header {
    font-size: 0.8rem;
    font-weight: bold;
    color: #e94560;
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid #333;
}

.message.user .message-header {
    color: #60a5fa;
    border-bottom-color: #3b82f6;
}

/* Message content wrapper */
.message-content {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ============================================================================
   Markdown Rendered Content
   ============================================================================ */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin: 0.25em 0 0.1em 0;
    font-weight: bold;
    line-height: 1.55;
}

.message-content h1 { font-size: 1.2em; color: #e94560; }
.message-content h2 { font-size: 1.1em; color: #e94560; }
.message-content h3 { font-size: 1.05em; color: #ccc; }
.message-content h4,
.message-content h5,
.message-content h6 { font-size: 1em; color: #aaa; }

.message-content p {
    margin: 0.2em 0;
    line-height: 1.75;
}

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

.message-content li {
    margin: 0;
    line-height: 1.7;
}

.message-content strong {
    font-weight: bold;
    color: #fff;
}

.message-content em {
    font-style: italic;
}

.message-content code {
    background: #0f3460;
    padding: 0.1em 0.3em;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}

.message-content pre {
    background: #0a1929;
    border: 1px solid #1e3a5f;
    border-radius: 4px;
    padding: 0.4em 0.6em;
    margin: 0.2em 0;
    overflow-x: auto;
}

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

.message-content blockquote {
    border-left: 3px solid #e94560;
    margin: 0.2em 0;
    padding: 0.25em 0.75em;
    background: rgba(233, 69, 96, 0.1);
    color: #ccc;
}

.message-content a {
    color: #60a5fa;
    text-decoration: underline;
}

.message-content a:hover {
    color: #93c5fd;
}

.message-content hr {
    border: none;
    border-top: 1px solid #333;
    margin: 0.3em 0;
}

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

.message-content th,
.message-content td {
    border: 1px solid #333;
    padding: 0.2em 0.4em;
    text-align: left;
}

.message-content th {
    background: #0f3460;
    font-weight: bold;
}

.message-content tr:nth-child(even) {
    background: rgba(15, 52, 96, 0.3);
}

/* ============================================================================
   Citations
   ============================================================================ */
.citations {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid #333;
    font-size: 0.8rem;
    color: #888;
}

.citations.loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-style: italic;
}

.citation-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #333;
    border-top-color: #e94560;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.citations-header {
    font-weight: bold;
    color: #666;
    margin-bottom: 0.25rem;
}

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

.citations li {
    padding: 0.2rem 0;
    padding-left: 1rem;
    position: relative;
}

.citations li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: #e94560;
}

/* ============================================================================
   Sources (Routing Matches - no LLM call needed)
   ============================================================================ */
.sources {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid #333;
    font-size: 0.8rem;
    color: #888;
}

.sources-header {
    font-weight: bold;
    color: #666;
    margin-bottom: 0.25rem;
}

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

.sources li {
    padding: 0.2rem 0;
    padding-left: 1rem;
    position: relative;
}

.sources li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: #e94560;
}

/* ============================================================================
   Loading States
   ============================================================================ */
.loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #888;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #333;
    border-top-color: #e94560;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ============================================================================
   Connecting Overlay (shown on page load)
   ============================================================================ */
.connecting-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1a1a2e;
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.connecting-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.connecting-content {
    text-align: center;
}

.connecting-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid #0f3460;
    border-top-color: #e94560;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1.5rem;
}

.connecting-text {
    color: #888;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
}

/* Loading overlay for agent loading */
#loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

#loading-overlay.active { display: flex; }

.loading-content {
    background: #16213e;
    border: 1px solid #e94560;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    min-width: 300px;
    max-width: 90vw;
}

.loading-content h3 {
    margin-bottom: 1rem;
    color: #e94560;
}

.loading-content .spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 1rem;
}

.progress-bar {
    background: #0f3460;
    border-radius: 4px;
    height: 20px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    background: linear-gradient(90deg, #e94560, #7c3aed);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.9rem;
    color: #888;
}

/* ============================================================================
   Input Area
   ============================================================================ */
#input-area {
    padding: 0.75rem 1rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    background: #16213e;
    border-top: 1px solid #0f3460;
    flex-shrink: 0;
}

/* Attachments container */
.attachments-container {
    display: none;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
}

.attachments-container.has-attachments {
    display: flex;
}

/* Attachment chip */
.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.6rem;
    background: rgba(233, 69, 96, 0.12);
    border: 1px solid rgba(233, 69, 96, 0.4);
    border-radius: 6px;
    font-size: 0.8rem;
    color: #eee;
    max-width: 220px;
    animation: chip-appear 0.15s ease-out;
}

@keyframes chip-appear {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.attachment-icon {
    font-size: 0.9rem;
    flex-shrink: 0;
}

.attachment-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.attachment-size {
    color: #888;
    font-size: 0.7rem;
    flex-shrink: 0;
}

.attachment-remove {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 0 0.15rem;
    font-size: 1.1rem;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s;
}

.attachment-remove:hover {
    color: #e94560;
}

#input-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid #333;
    border-radius: 8px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    position: relative;
    overflow: visible;
}

.toolbar-btn:hover {
    background: #0f3460;
    border-color: #444;
    color: #aaa;
}

.toolbar-btn.active {
    background: rgba(233, 69, 96, 0.15);
    border-color: #e94560;
    color: #e94560;
}

.toolbar-btn svg {
    flex-shrink: 0;
}

/* Web Search Depth Button States */
#web-search-btn .search-icon {
    display: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

#web-search-btn.depth-off .icon-off { display: block; }
#web-search-btn.depth-surface .icon-surface { display: block; }
#web-search-btn.depth-shallow .icon-shallow { display: block; }
#web-search-btn.depth-deep .icon-deep { display: block; }

/* Off state - muted */
#web-search-btn.depth-off {
    color: #555;
    border-color: #333;
}
#web-search-btn.depth-off:hover {
    color: #888;
    border-color: #444;
}

/* Surface state - blue glow */
#web-search-btn.depth-surface {
    color: #3b82f6;
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
}
#web-search-btn.depth-surface:hover {
    background: rgba(59, 130, 246, 0.2);
    box-shadow: 0 0 16px rgba(59, 130, 246, 0.4);
}

/* Shallow state - purple glow */
#web-search-btn.depth-shallow {
    color: #9333ea;
    border-color: #9333ea;
    background: rgba(147, 51, 234, 0.1);
    box-shadow: 0 0 12px rgba(147, 51, 234, 0.3);
}
#web-search-btn.depth-shallow:hover {
    background: rgba(147, 51, 234, 0.2);
    box-shadow: 0 0 16px rgba(147, 51, 234, 0.4);
}

/* Deep state - pink/magenta glow with pulse animation */
#web-search-btn.depth-deep {
    color: #ec4899;
    border-color: #ec4899;
    background: rgba(236, 72, 153, 0.1);
    box-shadow: 0 0 12px rgba(236, 72, 153, 0.3);
    animation: deep-pulse 2s ease-in-out infinite;
}
#web-search-btn.depth-deep:hover {
    background: rgba(236, 72, 153, 0.2);
    box-shadow: 0 0 20px rgba(236, 72, 153, 0.5);
}

@keyframes deep-pulse {
    0%, 100% { box-shadow: 0 0 12px rgba(236, 72, 153, 0.3); }
    50% { box-shadow: 0 0 20px rgba(236, 72, 153, 0.5); }
}

#message-input {
    flex: 1;
    background: #0f3460;
    color: #eee;
    border: 1px solid #333;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    min-height: 44px;
    line-height: 1.4;
}

#message-input:focus {
    outline: none;
    border-color: #e94560;
}

#send-btn {
    padding: 0 1.25rem;
    font-weight: bold;
    background: #e94560;
    border: 1px solid #e94560;
    border-radius: 4px;
    color: #fff;
    min-height: 44px;
    align-self: stretch;
    cursor: pointer;
}

#send-btn:hover:not(:disabled) {
    background: #d63a54;
}

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

/* ============================================================================
   Mobile Responsive
   ============================================================================ */
@media (max-width: 600px) {
    header {
        padding: 0.5rem 0.75rem;
    }

    header h1 {
        font-size: 1.1rem;
    }

    .header-status {
        font-size: 0.75rem;
        max-width: 140px;
    }

    #chat-container {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .message {
        max-width: 100%;
        padding: 0.625rem 0.75rem;
        border-radius: 6px;
    }

    #input-area {
        padding: 0.5rem;
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
        gap: 0.4rem;
    }

    #message-input {
        min-height: 50px;
        padding: 0.625rem 0.75rem;
        font-size: 16px; /* Prevents zoom on iOS */
        border-radius: 6px;
    }

    #send-btn {
        padding: 0 1rem;
        border-radius: 6px;
    }

    .toolbar-btn {
        width: 36px;
        height: 36px;
    }

    .menu-panel {
        width: 336px;
    }
}

/* ============================================================================
   Utility Classes
   ============================================================================ */
.help-text {
    font-family: monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

.help-text .cmd { color: #e94560; }
.help-text .desc { color: #888; }

/* ============================================================================
   Conversation History List (in hamburger menu)
   ============================================================================ */
.conversations-section {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

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

.section-header label {
    margin-bottom: 0;
}

.icon-btn {
    width: 28px;
    height: 28px;
    background: transparent;
    border: 1px solid #333;
    border-radius: 4px;
    color: #888;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: #0f3460;
    border-color: #e94560;
    color: #e94560;
}

.icon-btn.spinning {
    animation: spin 1s linear infinite;
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    margin: 0.25rem 0 0.5rem 0;
    min-height: 120px;
    max-height: 280px;
}

.conversation-item {
    padding: 0.625rem 0.75rem;
    border: 1px solid #0f3460;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.conversation-item:hover {
    background: rgba(15, 52, 96, 0.5);
    border-color: #1a5a9a;
}

.conversation-item.active {
    border-color: #e94560;
    background: rgba(233, 69, 96, 0.1);
}

.conversation-item.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #e94560;
    border-radius: 6px 0 0 6px;
}

.conversation-preview {
    font-size: 0.85rem;
    color: #ddd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.35rem;
    padding-right: 1.5rem;
}

.conversation-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    color: #666;
}

.conversation-time {
    color: #888;
}

.conversation-agent {
    color: #e94560;
    font-weight: 500;
}

.conversation-header {
    margin-bottom: 0.35rem;
}

.conversation-agent-badge,
.conversation-collection-badge,
.conversation-model-badge {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
}

.conversation-agent-badge {
    background: rgba(233, 69, 96, 0.2);
    color: #e94560;
}

.conversation-collection-badge {
    background: rgba(37, 99, 235, 0.2);
    color: #60a5fa;
}

.conversation-model-badge {
    background: rgba(148, 163, 184, 0.2);
    color: #94a3b8;
}

.conversation-count {
    background: #0f3460;
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
    font-size: 0.65rem;
}

.conversation-delete {
    position: absolute;
    right: 0.5rem;
    top: 0.5rem;
    background: transparent;
    border: 1px solid #333;
    color: #666;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.conversation-delete:hover {
    color: #e94560;
    border-color: #e94560;
    background: rgba(233, 69, 96, 0.15);
}

/* Fade out animation for deleted items */
.conversation-item.deleting {
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Inline confirmation (load/delete) */
.conversation-item.confirming-delete,
.conversation-item.confirming-load {
    border-color: #e94560;
}

.conversation-item.confirming-delete {
    background: rgba(233, 69, 96, 0.1);
}

.conversation-item.confirming-load {
    background: rgba(5, 150, 105, 0.15);
    border-color: #059669;
}

.conversation-item.confirming-delete .conversation-header,
.conversation-item.confirming-delete .conversation-preview,
.conversation-item.confirming-delete .conversation-meta,
.conversation-item.confirming-delete .conversation-delete,
.conversation-item.confirming-load .conversation-header,
.conversation-item.confirming-load .conversation-preview,
.conversation-item.confirming-load .conversation-meta,
.conversation-item.confirming-load .conversation-delete {
    display: none;
}

.confirm-content,
.load-confirm-content {
    display: none;
}

.conversation-item.confirming-delete .confirm-content,
.conversation-item.confirming-load .load-confirm-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.confirm-text {
    font-size: 0.8rem;
    color: #e94560;
}

.load-confirm-content .confirm-text {
    color: #059669;
    flex: 1;
}

.confirm-buttons {
    display: flex;
    gap: 0.4rem;
}

.confirm-buttons button {
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    transition: background 0.2s;
}

.confirm-buttons .confirm-yes {
    background: #e94560;
    color: #fff;
}

.confirm-buttons .confirm-yes:hover {
    background: #d63a54;
}

.confirm-buttons .confirm-no {
    background: #0f3460;
    color: #ccc;
}

.confirm-buttons .confirm-no:hover {
    background: #1a4a7a;
}

.confirm-buttons .confirm-load {
    background: #059669;
    color: #fff;
}

.confirm-buttons .confirm-load:hover {
    background: #047857;
}

.conversations-empty {
    text-align: center;
    color: #555;
    padding: 1.5rem 1rem;
    font-size: 0.85rem;
    font-style: italic;
}

.conversations-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    color: #888;
    font-size: 0.85rem;
}

.conversations-loading .spinner {
    width: 16px;
    height: 16px;
}

.load-more-btn {
    width: 100%;
    padding: 0.5rem;
    background: transparent;
    color: #888;
    border: 1px dashed #333;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.load-more-btn:hover {
    background: #0f3460;
    border-color: #e94560;
    border-style: solid;
    color: #eee;
}

/* ============================================================================
   Model Manager Modal
   ============================================================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 400;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-close {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: #888;
    font-size: 1.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
    line-height: 1;
}

.modal-close:hover {
    background: rgba(233, 69, 96, 0.2);
    color: #e94560;
}

.model-manager-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 90vw;
    max-width: 800px;
    height: 80vh;
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 8px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
}

.model-manager-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.model-manager-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #0f3460;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.model-manager-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: #e94560;
    margin: 0;
}

/* Model manager toolbar - compact filter area */
.model-manager-toolbar {
    padding: 0.75rem 1rem;
    background: #0f3460;
    border-bottom: 1px solid #1a3a5c;
    flex-shrink: 0;
}

.toolbar-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.toolbar-row + .toolbar-row {
    margin-top: 0.5rem;
}

.toolbar-options {
    justify-content: space-between;
}

.toolbar-checkboxes {
    display: flex;
    gap: 0.75rem;
}

.toolbar-usage {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.model-search {
    flex: 1;
    padding: 0.4rem 0.6rem;
    background: #1a1a2e;
    color: #eee;
    border: 1px solid #333;
    border-radius: 4px;
    font-size: 0.85rem;
}

.model-search:focus {
    outline: none;
    border-color: #e94560;
}

.model-search::placeholder {
    color: #666;
}

.toolbar-select {
    padding: 0.4rem 0.6rem;
    background: #1a1a2e;
    color: #eee;
    border: 1px solid #333;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
}

.toolbar-select:focus {
    outline: none;
    border-color: #e94560;
}

.toolbar-select-sm {
    padding: 0.25rem 0.4rem;
    background: #1a1a2e;
    color: #aaa;
    border: 1px solid #333;
    border-radius: 3px;
    font-size: 0.75rem;
    cursor: pointer;
}

.toolbar-select-sm:focus {
    outline: none;
    border-color: #e94560;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: #888;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: #e94560;
    cursor: pointer;
}

/* Inline usage display */
.usage-inline {
    font-size: 0.75rem;
    color: #888;
    margin-left: 0.25rem;
}

.usage-inline .usage-calls {
    color: #10b981;
    font-weight: 500;
}

.usage-inline .usage-provider {
    color: #aaa;
    margin-right: 0.35rem;
}

.usage-inline .usage-tokens {
    color: #3b82f6;
}

.usage-inline .usage-empty {
    color: #666;
    font-style: italic;
}

.model-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
}

.model-loading,
.model-error,
.model-empty {
    text-align: center;
    padding: 2rem;
    color: #888;
}

.model-error {
    color: #e94560;
}

/* Model accordion groups */
.model-accordion {
    margin-bottom: 0.5rem;
    border-radius: 6px;
    overflow: hidden;
    background: #0a1628;
    border: 1px solid #1a3a5c;
}

.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.75rem;
    background: #0f2847;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.accordion-header:hover {
    background: #143356;
}

.accordion-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.accordion-icon {
    font-size: 0.85rem;
}

.accordion-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: #ddd;
}

.accordion-count {
    font-size: 0.65rem;
    color: #888;
    background: #1a1a2e;
    padding: 0.1rem 0.35rem;
    border-radius: 8px;
    margin-left: 0.25rem;
}

.accordion-chevron {
    font-size: 0.7rem;
    color: #666;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.model-accordion.expanded .accordion-chevron {
    transform: rotate(180deg);
}

.accordion-content {
    height: 0;
    overflow: hidden;
    transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.accordion-inner {
    padding: 0.375rem;
}

.model-card {
    background: #0f3460;
    border: 1px solid #2a4a6c;
    border-radius: 4px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.375rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.model-card:last-child {
    margin-bottom: 0;
}

.model-card:hover {
    border-color: #555;
}

.model-card.selected {
    border-color: #e94560;
    background: rgba(233, 69, 96, 0.1);
}

.model-card.unavailable {
    opacity: 0.5;
    cursor: not-allowed;
}

.model-card.current {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.model-card-content {
    flex: 1;
    min-width: 0;
}

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

.model-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #eee;
}

.model-badges {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.badge {
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge.free {
    background: #10b981;
    color: #fff;
}

.badge.reasoning {
    background: #8b5cf6;
    color: #fff;
}

.badge.unavailable {
    background: #ef4444;
    color: #fff;
}

.badge.current {
    background: #3b82f6;
    color: #fff;
}

.model-card-details {
    display: flex;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: #777;
    margin-bottom: 0.2rem;
}

.model-description {
    font-size: 0.75rem;
    color: #888;
    line-height: 1.3;
}

.model-usage {
    margin-top: 0.3rem;
    display: flex;
    gap: 0.5rem;
    font-size: 0.7rem;
    color: #777;
}

.model-usage .usage-chats {
    color: #10b981;
    font-weight: 500;
}

.model-usage .usage-tokens {
    color: #666;
}

.model-manager-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid #0f3460;
    flex-shrink: 0;
}

/* Mobile responsive */
@media (max-width: 600px) {
    .model-manager-panel {
        /* Full screen on mobile - use dvh for dynamic viewport height */
        top: 0;
        left: 0;
        transform: none;
        width: 100vw;
        height: 100dvh;
        max-width: none;
        max-height: none;
        border-radius: 0;
        border: none;
    }

    .model-manager-panel.open {
        transform: none;
    }

    .model-manager-header {
        padding: 0.5rem 0.75rem;
    }

    .model-manager-toolbar {
        padding: 0.5rem 0.75rem;
    }

    .toolbar-row {
        flex-wrap: wrap;
    }

    .toolbar-options {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .toolbar-usage {
        flex-wrap: wrap;
    }

    .model-list {
        padding: 0.5rem;
    }

    .accordion-header {
        padding: 0.5rem 0.625rem;
    }

    .accordion-inner {
        padding: 0.25rem;
    }

    .model-card {
        padding: 0.5rem 0.625rem;
    }

    .model-card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .model-badges {
        margin-top: 0.2rem;
    }

    .model-manager-footer {
        padding: 0.625rem 0.75rem;
    }
}


/* ============================================================================
   Agent & Collection Manager Modals
   ============================================================================ */

.context-manager-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 90vw;
    max-width: 500px;
    max-height: 70vh;
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 8px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
}

.context-manager-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.context-manager-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #0f3460;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.context-manager-header h2 {
    font-size: 1.1rem;
    color: #e94560;
}

.context-manager-search {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #0f3460;
    flex-shrink: 0;
}

.context-manager-search input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: #0f3460;
    color: #eee;
    border: 1px solid #333;
    border-radius: 4px;
    font-size: 0.9rem;
}

.context-manager-search input:focus {
    outline: none;
    border-color: #e94560;
}

.context-manager-search input::placeholder {
    color: #666;
}

.context-manager-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1.25rem;
}

.context-manager-empty {
    text-align: center;
    padding: 2rem;
    color: #888;
    font-style: italic;
}

/* Context card (agent or collection) */
.context-card {
    background: #0f3460;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.context-card:hover {
    border-color: #555;
}

.context-card.selected {
    border-color: #e94560;
    background: rgba(233, 69, 96, 0.1);
}

.context-card.current {
    border-color: #10b981;
}

.context-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.context-card-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: #eee;
}

.context-card-badges {
    display: flex;
    gap: 0.4rem;
}

.context-card-meta {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 0.25rem;
}

.context-card-description {
    font-size: 0.8rem;
    color: #aaa;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.context-manager-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid #0f3460;
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
}

.context-manager-footer .btn-secondary {
    flex: 0 0 auto;
}

.context-manager-footer .btn-primary {
    flex: 1;
}

/* Clear button styling */
.btn-secondary {
    padding: 0.5rem 0.75rem;
    background: transparent;
    color: #888;
    border: 1px solid #333;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.btn-secondary:hover {
    border-color: #555;
    color: #aaa;
}

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

/* Mobile responsive for context managers */
@media (max-width: 600px) {
    .context-manager-panel {
        top: 0;
        left: 0;
        transform: none;
        width: 100vw;
        height: 100dvh;
        max-width: none;
        max-height: none;
        border-radius: 0;
        border: none;
    }

    .context-manager-panel.open {
        transform: none;
    }

    .context-manager-header {
        padding: 0.75rem 1rem;
    }

    .context-manager-search {
        padding: 0.5rem 1rem;
    }

    .context-manager-list {
        padding: 0.5rem 1rem;
    }

    .context-manager-footer {
        padding: 0.75rem 1rem;
    }
}


/* ============================================================================
   Attachment Chips (in messages)
   ============================================================================ */

.message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.5rem;
    background: rgba(233, 69, 96, 0.15);
    border: 1px solid #e94560;
    border-radius: 6px;
    font-size: 0.8rem;
    color: #eee;
    max-width: 200px;
}

.attachment-chip.clickable {
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.attachment-chip.clickable:hover {
    background: rgba(233, 69, 96, 0.25);
    border-color: #ff6b81;
}

.attachment-icon {
    flex-shrink: 0;
}

.attachment-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-size {
    color: #888;
    font-size: 0.75rem;
    flex-shrink: 0;
}


/* ============================================================================
   Attachment Viewer Modal
   ============================================================================ */

.attachment-viewer-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 90vw;
    max-width: 900px;
    max-height: 80vh;
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 8px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
}

.attachment-viewer-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.attachment-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #0f3460;
}

.attachment-viewer-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #eee;
    font-weight: 500;
}

.attachment-viewer-content {
    flex: 1;
    overflow: auto;
    padding: 1rem;
    background: #0d1525;
}

.attachment-viewer-content pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    color: #ddd;
}

.attachment-viewer-content code {
    background: transparent;
    padding: 0;
}

.attachment-viewer-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid #0f3460;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.attachment-viewer-footer .menu-btn.success {
    background: #27ae60;
    border-color: #27ae60;
}

/* Mobile: full screen attachment viewer */
@media (max-width: 600px) {
    .attachment-viewer-panel {
        top: 0;
        left: 0;
        transform: none;
        width: 100vw;
        height: 100dvh;
        max-width: none;
        max-height: none;
        border-radius: 0;
    }

    .attachment-viewer-panel.open {
        transform: none;
    }
}



/* ============================================================================
   Login Modal (Remote Access Authentication)
   ============================================================================ */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1a1a2e;
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.login-overlay.active {
    opacity: 1;
    visibility: visible;
}

.login-panel {
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-title {
    font-size: 2rem;
    font-weight: 700;
    color: #e94560;
    margin: 0 0 0.5rem 0;
    letter-spacing: -0.5px;
}

.login-subtitle {
    color: #888;
    margin: 0;
    font-size: 0.95rem;
}

.login-body {
    display: flex;
    flex-direction: column;
}

.login-field {
    margin-bottom: 1rem;
}

.login-field input {
    width: 100%;
    padding: 0.9rem 1rem;
    background: #0f3460;
    border: 1px solid #1a4a7a;
    border-radius: 8px;
    color: #eee;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-field input:focus {
    border-color: #e94560;
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.15);
}

.login-field input::placeholder {
    color: #666;
}

.login-error {
    color: #f87171;
    font-size: 0.85rem;
    min-height: 1.2em;
    margin-bottom: 1rem;
    text-align: center;
}

.login-btn {
    width: 100%;
    padding: 0.9rem;
    background: linear-gradient(135deg, #e94560, #7c3aed);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.login-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(233, 69, 96, 0.4);
}

.login-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Mobile login */
@media (max-width: 480px) {
    .login-panel {
        margin: 1rem;
        padding: 2rem 1.5rem;
    }
}
