/* Praxis Chat - Main Stylesheet */

/* ==================== CSS Variables ==================== */
:root {
    --primary: #18453B;
    --primary-light: #0B9A6D;
    --primary-dark: #18453B;
    --background: #f9f9f9;
    --text: #333333;
    --light-text: #666666;
    --user-message-bg: #e8f5e9;
    --assistant-message-bg: #ffffff;
    --border: #d0d0d0;
    --shadow: rgba(0, 0, 0, 0.05);
    
    /* Unified spacing variables */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 0.75rem;
    --spacing-lg: 1.25rem;
    --spacing-xl: 1.5rem;
    
    /* Unified border radius variables */
    --radius-small: 6px;
    --radius-medium: 6px;
    --radius-large: 6px;
    --radius-round: 50%;
    
    /* Unified size variables */
    --icon-size: 1.5em;
    --icon-font-size: 0.85em;
    --icon-element-size: 0.85em;  /* Size of the "P" element symbol */
    --icon-padding: 0.5em;
    --seed-font-size: 0.2em;
}

[data-theme="dark"] {
    --primary: #18453B;
    --primary-light: #0B9A6D;
    --primary-dark: #0B9A6D;
    --background: #121212;
    --text: #e0e0e0;
    --light-text: #b0b0b0;
    --user-message-bg: #18453B;
    --assistant-message-bg: #1e1e1e;
    --border: #333333;
    --shadow: rgba(0, 0, 0, 0.3);
    --input-bg: #1e1e1e;
    --input-text: #e0e0e0;
}

/* ==================== Global Styles ==================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    height: 100%;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

/* ==================== Layout ==================== */
.app-container {
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    height: 100vh;
    height: 100dvh;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 22px;
    overflow: hidden;
}

/* ==================== Header ==================== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0 1px 0;
    background-color: var(--background);
    z-index: 10;
}

.logo {
    font-size: 24px;
    font-weight: 600;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 1;
}

.tesla-logo {
    width: 112px;
    height: 112px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    flex-grow: 0;
    position: relative;
    overflow: visible;
}

.tesla-logo canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 140px;
    height: 140px;
    image-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Keep old logo-icon styles for backwards compatibility */
.logo-icon {
    width: var(--icon-size);
    height: var(--icon-size);
    min-width: var(--icon-size);
    min-height: var(--icon-size);
    max-width: var(--icon-size);
    max-height: var(--icon-size);
    background-color: var(--primary);
    border-radius: var(--radius-small);
    display: flex;
    flex-direction: column;
    color: white;
    font-weight: bold;
    flex-shrink: 0;
    flex-grow: 0;
    position: relative;
    padding: var(--icon-padding);
}

.logo-icon::before {
    content: attr(data-seed);
    position: absolute;
    top: 0px;
    right: 0px;
    padding: 1em 1em 0em 0em;
    font-size: var(--seed-font-size);
    font-weight: 500;
    color: white;
    line-height: 1;
    opacity: 0.9;
}

.logo-icon::after {
    content: "P";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: var(--icon-element-size);
    font-weight: bold;
    color: white;
    line-height: 1;
}

.logo-separator {
    color: var(--border);
    font-weight: 300;
    margin: 0 10px;
}

.system-prompt-header {
    font-size: 14px;
    font-weight: 400;
    color: var(--light-text);
    font-style: italic;
    cursor: text;
    padding: 4px 8px 4px 0;
    border-radius: var(--radius-small);
    transition: background-color 0.2s, max-width 0.2s;
    outline: none;
    flex: 1;
    max-width: 600px;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
}

.system-prompt-header:hover {
    background-color: rgba(0, 0, 0, 0.02);
    max-width: 800px;
}

.system-prompt-header:focus {
    background-color: rgba(0, 0, 0, 0.03);
    box-shadow: 0 0 0 1px var(--border);
    white-space: pre-wrap;
    overflow: visible;
    max-width: 800px;
    line-clamp: unset;
    -webkit-line-clamp: unset;
    display: block;
}

[data-theme="dark"] .system-prompt-header:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .system-prompt-header:focus {
    background-color: rgba(255, 255, 255, 0.08);
}

/* ==================== Buttons ==================== */
.settings-button,
.theme-toggle-button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--light-text);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    border-radius: var(--radius-small);
    transition: background-color 0.2s;
}

.theme-toggle-button {
    margin-right: 8px;
}

.settings-button:hover,
.theme-toggle-button:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .settings-button:hover,
[data-theme="dark"] .theme-toggle-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* ==================== Modal ==================== */
.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    padding: 20px;
    overflow-y: auto;
}

.settings-modal.open {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--background);
    padding: 30px;
    border-radius: var(--radius-small);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border);
    color: var(--text);
    margin: auto;
    position: relative;
}

[data-theme="dark"] .modal-content {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.close-button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: var(--light-text);
}

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

/* ==================== Forms ==================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text);
}

.form-group label input[type="checkbox"] {
    width: auto;
    margin: 0;
    margin-right: 10px;
    cursor: pointer;
    vertical-align: middle;
}

.form-group input:not([type="checkbox"]) {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    font-size: 14px;
    background-color: var(--input-bg, var(--assistant-message-bg));
    color: var(--input-text, #333333);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.save-button, .reset-button {
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: var(--radius-small);
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

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

.save-button:hover {
    background-color: var(--primary-dark);
}

.reset-button {
    background-color: #d32f2f;
}

.reset-button:hover {
    background-color: #b71c1c;
}

.save-confirmation {
    display: none;
    margin-top: 15px;
    padding: 12px;
    background-color: var(--primary-light);
    color: white;
    border-radius: var(--radius-small);
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    animation: fadeIn 0.3s ease-in;
}

.save-confirmation.show {
    display: block;
}

/* ==================== Chat Container ==================== */
.chat-container {
    overflow-y: auto;
    padding: var(--spacing-md) var(--spacing-lg) 0 var(--spacing-lg);
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* ==================== Messages ==================== */
.message {
    margin-bottom: var(--spacing-md);
    max-width: 75%;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-medium);
    box-shadow: 0 1px 2px var(--shadow);
    position: relative;
    animation: fadeIn 0.3s forwards;
}

.message.user {
    align-self: flex-end;
    background-color: var(--user-message-bg);
}

.message.assistant {
    align-self: flex-start;
    background-color: var(--assistant-message-bg);
    border: 1px solid var(--border);
}

.message:last-child {
    margin-bottom: var(--spacing-lg);
}

.message-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 600;
}

.header-name {
    font-weight: 600;
}

.thinking-status {
    font-weight: normal;
    color: var(--light-text);
    font-style: italic;
}

.error-header {
    color: #cc0000;
    font-weight: 600;
}

[data-theme="dark"] .error-header {
    color: #ff6666;
}

/* Message header colors */
.message.user .message-header {
    color: #1a5a1a;
}

.message.assistant .message-header {
    color: #333333;
}

[data-theme="dark"] .message.user .message-header {
    color: #a8d5a8;
}

[data-theme="dark"] .message.assistant .message-header {
    color: #b0b0b0;
}

.message-content {
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message.user .message-content {
    color: #1a1a1a;
}

.message.assistant .message-content {
    color: #333333;
}

[data-theme="dark"] .message.user .message-content {
    color: #ffffff;
}

[data-theme="dark"] .message.assistant .message-content {
    color: #e0e0e0;
}

.assistant .message-content {
    line-height: 1.7;
}

.reroll-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
    color: var(--light-text);
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.reroll-button:hover {
    background-color: var(--user-message-bg);
    color: var(--text);
}

.message.assistant:last-of-type:hover .reroll-button {
    opacity: 1;
}

/* ==================== Loading Animation ==================== */
.dots {
    display: inline-flex;
    gap: 4px;
    margin-left: 4px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-round);
    background-color: var(--primary);
    opacity: 0.7;
}

.dot:nth-child(1) { animation: bounce 1.2s infinite 0s; }
.dot:nth-child(2) { animation: bounce 1.2s infinite 0.2s; }
.dot:nth-child(3) { animation: bounce 1.2s infinite 0.4s; }

/* ==================== Input Container ==================== */
.input-container {
    display: flex;
    padding: 0 0 var(--spacing-xl) 0;
    padding-bottom: calc(var(--spacing-xl) + env(safe-area-inset-bottom));
    background-color: var(--background);
    z-index: 10;
}

.input-container.with-messages {
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--border);
    margin-top: 0;
}

.message-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    font-size: 16px;
    resize: none;
    min-height: 44px;
    max-height: 200px;
    overflow-y: hidden;
    transition: border-color 0.2s;
    font-family: inherit;
    background-color: var(--input-bg, var(--background));
    color: var(--input-text, var(--text));
    line-height: 1.5;
}

.message-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ==================== Tab Navigation ==================== */
.tab-nav {
    display: flex;
    gap: 10px;
    padding: 5px 20px 10px 20px;
    border-bottom: 1px solid var(--border);
    background-color: var(--background);
    position: relative;
    justify-content: space-between;
    align-items: center;
}

.tab-buttons {
    display: flex;
    gap: 10px;
    min-width: 0;
}

.tab-button {
    padding: 10px 16px;
    background: var(--surface);
    border: none;
    color: var(--light-text);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-small);
    transition: all 0.2s;
    position: relative;
    white-space: nowrap;
    flex: 0 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-button:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text);
}

[data-theme="dark"] .tab-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.tab-button.active {
    color: var(--primary-dark);
    background-color: var(--user-message-bg);
}

/* Subtle white highlight for active tab in dark mode */
[data-theme="dark"] .tab-button.active {
    color: #FFFFFF; /* White from palette */
    background-color: rgba(255, 255, 255, 0.08); /* Very subtle white background */
    text-shadow:
        0 0 6px rgba(255, 255, 255, 0.4),
        0 0 12px rgba(255, 255, 255, 0.2);
    animation: subtleGlow 3s ease-in-out infinite alternate;
}

/* Subtle bloom effect on active tab in dark mode */
[data-theme="dark"] .tab-button.active::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.1) 0%, transparent 60%);
    border-radius: var(--radius-small);
    z-index: -1;
    opacity: 0.5;
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: -11px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--primary);
}

/* Enhance the bottom border for dark mode with subtle glow */
[data-theme="dark"] .tab-button.active::after {
    background: linear-gradient(90deg,
        transparent,
        #FFFFFF 10%,
        #FFFFFF 90%,
        transparent
    );
    box-shadow:
        0 0 6px rgba(255, 255, 255, 0.5),
        0 -1px 4px rgba(255, 255, 255, 0.3);
}

/* Subtle glow animation */
@keyframes subtleGlow {
    0% {
        text-shadow:
            0 0 6px rgba(255, 255, 255, 0.4),
            0 0 12px rgba(255, 255, 255, 0.2);
    }
    100% {
        text-shadow:
            0 0 8px rgba(255, 255, 255, 0.5),
            0 0 14px rgba(255, 255, 255, 0.3);
    }
}

.tab-content {
    display: none;
    height: 100%;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

#terminal-content {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ==================== Terminal Styles ==================== */
.terminal-container {
    flex: 1;
    background-color: var(--background);
    color: #d4d4d4;
    font-family: 'Cascadia Code', 'Fira Code', 'Monaco', 'Courier New', monospace;
    font-size: 10px;
    line-height: 1.0;
    padding: 10px;
    overflow: auto;
    white-space: pre;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

[data-theme="dark"] .terminal-container {
    background-color: var(--background);
}

.terminal-line {
    min-height: 1.4em;
    white-space: pre-wrap;
    word-wrap: break-word;
    background-color: transparent;
    color: var(--text);
    padding: 2px 5px;
}

.terminal-status {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: var(--light-text);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 10px;
    border-radius: var(--radius-small);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-round);
    background-color: #666;
    transition: background-color 0.3s;
}

.status-indicator.connected {
    background-color: #18453B;
    box-shadow: 0 0 4px rgba(24, 69, 59, 0.4);
}

/* ==================== Dashboard Styles ==================== */
.dashboard-wrapper {
    overflow: hidden !important;
    max-width: 100%;
    position: relative;
    background-color: #0d0d0d !important;
}

.dashboard-frame {
    background-color: #0d0d0d !important;
    color: #d4d4d4 !important;
    padding: 8px;
    border-radius: var(--radius-small);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    display: inline-block;
    font-family: 'Courier New', Courier, 'Lucida Console', monospace;
    font-size: 10px;
    line-height: 1.2;
    letter-spacing: 0;
    font-variant-ligatures: none;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: auto;
    text-rendering: optimizeSpeed;
    font-feature-settings: "liga" 0, "calt" 0;
}

.dashboard-line {
    white-space: pre;
    margin: 0;
    padding: 0;
    background-color: transparent !important;
    color: inherit !important;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    letter-spacing: inherit;
}

/* ==================== Spec Tab Styles ==================== */
.spec-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: var(--background);
}

.spec-section {
    margin-bottom: 30px;
}

.spec-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
}

.spec-metadata {
    font-size: 14px;
    color: var(--light-text);
    margin-bottom: 8px;
    font-family: 'Inter', sans-serif;
}

.spec-hash {
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 13px;
    margin-bottom: 16px;
}

.spec-code {
    background-color: #f5f5f5;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    padding: 16px;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 13px;
    color: #333;
    white-space: pre;
    overflow-x: auto;
}

[data-theme="dark"] .spec-code {
    background-color: #1e1e1e;
    color: #e0e0e0;
}

/* ==================== Agents Tab Styles ==================== */
.agents-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: var(--background);
}

.agents-section {
    margin-bottom: 30px;
}

.agents-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
}

.agents-table {
    width: 100%;
    max-width: 800px;
    background-color: var(--assistant-message-bg);
    border-radius: var(--radius-small);
    overflow: hidden;
    box-shadow: 0 2px 10px var(--shadow);
}

.agents-list {
    padding: 0;
}

.agent-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s;
}

.agent-row:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .agent-row:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.agent-row:last-child {
    border-bottom: none;
}

.agent-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.agent-name {
    font-size: 16px;
    font-weight: 500;
    color: var(--text);
}

.agent-url {
    font-size: 13px;
    color: var(--light-text);
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    word-break: break-all;
}

.agent-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: var(--radius-medium);
    font-size: 13px;
    font-weight: 500;
}

.agent-status.online {
    background-color: rgba(11, 154, 109, 0.1);
    color: var(--primary-light);
}

.agent-status.archived {
    background-color: rgba(0, 39, 76, 0.1);
    color: #00274c;
}

.agent-status.offline {
    background-color: rgba(102, 102, 102, 0.1);
    color: var(--light-text);
}

.agent-status.ambiguous {
    background-color: rgba(255, 203, 5, 0.15);
    color: #FFCB05;
}

[data-theme="dark"] .agent-status.online {
    background-color: rgba(11, 154, 109, 0.2);
    color: var(--primary-light);
}

[data-theme="dark"] .agent-status.archived {
    background-color: rgba(0, 39, 76, 0.3);
    color: #5b8fc9;
}

[data-theme="dark"] .agent-status.offline {
    background-color: rgba(176, 176, 176, 0.1);
    color: var(--light-text);
}

[data-theme="dark"] .agent-status.ambiguous {
    background-color: rgba(255, 203, 5, 0.2);
    color: #FFCB05;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-round);
}

.status-dot.online {
    background-color: var(--primary-light);
    animation: pulse 2s infinite;
}

.status-dot.archived {
    background-color: #00274c;
}

.status-dot.offline {
    background-color: var(--light-text);
}

.status-dot.ambiguous {
    background-color: #FFCB05;
    animation: pulse-harsh 1.5s infinite linear;
}

.agents-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--light-text);
}

.agents-error {
    padding: 20px;
    color: #c62828;
    background-color: #ffebee;
    border-radius: var(--radius-small);
    margin: 20px;
}

[data-theme="dark"] .agents-error {
    color: #ef9a9a;
    background-color: #b71c1c;
}

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

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

@keyframes pulse-harsh {
    0% { opacity: 1; }
    50% { opacity: 0; }
    100% { opacity: 1; }
}

/* ==================== Utility Classes ==================== */
.hidden {
    display: none;
}

/* Utility classes for inline styles from HTML */
.header-actions {
    display: flex;
    align-items: center;
}

.loading-placeholder {
    padding: 20px;
    color: var(--light-text);
}

.modal-subheading {
    margin-top: 20px;
    margin-bottom: 15px;
    font-weight: 500;
    color: var(--text);
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* ==================== Mobile Responsive ==================== */
@media (max-width: 768px) {
    body {
        overflow-x: hidden; /* Prevent buttons from appearing in body */
        position: relative;
        z-index: 1;
        background: var(--background); /* Ensure solid background */
    }
    
    .app-container {
        padding: 0 20px;
        overflow: hidden; /* Prevent any overflow of fading buttons */
        position: relative;
        z-index: 2;
        background: var(--background); /* Ensure solid background to hide buttons */
    }
    
    /* Create solid overlays to hide buttons that escape tab-nav */
    .app-container::before,
    .app-container::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        width: 20px; /* Match the padding */
        background: var(--background);
        z-index: 5; /* Above the tab-nav content */
    }
    
    .app-container::before {
        left: 0;
    }
    
    .app-container::after {
        right: 0;
    }
    
    .header {
        padding: 10px 0;
    }
    
    .logo {
        font-size: 18px;
        gap: 8px;
    }
    
    .logo-text,
    .logo-separator {
        display: none;
    }
    
    .tab-nav {
        padding: 5px 10px 10px 10px;
        position: relative;
        overflow: visible; /* Allow overflow for fade effect */
        z-index: 0; /* Lower than app-container */
    }
    
    /* Subtle edge indicators */
    .tab-nav::before,
    .tab-nav::after {
        content: '';
        position: absolute;
        top: 5px;
        bottom: 10px;
        width: 15px;
        pointer-events: none;
        z-index: 10;
        opacity: 0;
        transition: opacity 0.3s;
    }
    
    .tab-nav::before {
        left: 0;
        background: linear-gradient(to right, var(--background), transparent);
    }
    
    .tab-nav::after {
        right: 0;
        background: linear-gradient(to left, var(--background), transparent);
    }
    
    .tab-nav.has-scroll-left::before {
        opacity: 0.6;
    }
    
    .tab-nav.has-scroll-right::after {
        opacity: 0.6;
    }
    
    .tab-buttons {
        display: flex;
        gap: 6px;
        max-width: calc(100% - 120px);
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        /* Hide scrollbar */
        scrollbar-width: none;
        -ms-overflow-style: none;
        /* Extend the scrollable area into the left margin */
        padding-left: 40px;
        padding-right: 20px;
        margin-left: -40px;
        position: relative;
        z-index: 0; /* Ensure buttons stay below parent containers */
        /* Mask gradient: fade zone is between tab-buttons edge and tab-nav edge */
        /* Transparent at 0 (tab-nav edge), fade to black by 40px (tab-buttons visible edge) */
        -webkit-mask-image: linear-gradient(
            to right,
            transparent 0px,
            black 40px,
            black calc(100% - 20px),
            transparent 100%
        );
        mask-image: linear-gradient(
            to right,
            transparent 0px,
            black 40px,
            black calc(100% - 20px),
            transparent 100%
        );
    }
    
    .tab-buttons::-webkit-scrollbar {
        display: none;
    }
    
    /* Invisible spacer to allow last button to reach center */
    .tab-buttons::after {
        content: '';
        display: block;
        flex-shrink: 0;
        width: 50%;
        height: 1px;
    }
    
    .tab-button {
        padding: 10px 12px;
        font-size: 13px;
        flex: 0 0 auto;  /* Prevent buttons from shrinking */
        white-space: nowrap;  /* Keep text on one line */
    }
    
    .logo-icon {
        width: var(--icon-size);
        height: var(--icon-size);
    }
    
    .system-prompt-header {
        font-size: 11px;
        max-width: none;
        flex: 1;
        line-clamp: 2;
        -webkit-line-clamp: 2;
        line-height: 1.3;
        margin-right: 10px;
    }
    
    .system-prompt-header:focus {
        max-width: none;
        line-clamp: unset;
        -webkit-line-clamp: unset;
        font-size: 12px;
    }

    .message {
        max-width: 85%;
    }
    
    .terminal-container {
        font-size: 10px;
        line-height: 1.0;
        padding: 10px;
        overflow: hidden;
        white-space: pre;
        position: relative;
        min-height: 100%;
    }
    
    .dashboard-frame {
        background-color: #1e1e1e;
        color: #d4d4d4;
        padding: 8px;
        border-radius: var(--radius-small);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        display: inline-block;
        font-family: monospace;
        font-size: 10px;
        line-height: 1.0;
        width: max-content;
        min-width: 100%;
    }
    
    .dashboard-line {
        font-size: inherit;
        white-space: nowrap;
    }
    
    .tab-content.active {
        min-height: calc(100vh - 120px);
    }
    
    .terminal-container {
        font-size: 8px;
        padding: 5px;
        min-height: auto;
        overflow: hidden !important;
    }
    
    .dashboard-frame {
        padding: 4px;
        font-size: 8px;
        display: inline-block;
        overflow: visible;
        font-family: monospace, 'Courier', 'Courier New' !important;
        font-weight: normal !important;
        font-style: normal !important;
        text-transform: none !important;
        word-spacing: 0 !important;
        letter-spacing: 0 !important;
        line-height: 1.0 !important;
        -webkit-text-size-adjust: 100%;
        -webkit-font-smoothing: none !important;
        text-rendering: optimizeLegibility !important;
        font-variant-numeric: tabular-nums !important;
    }
    
    #terminal-content {
        height: calc(100vh - 120px);
        overflow-y: auto;
    }
}

/* Ultra-compact mode for very small screens */
@media (max-width: 360px) {
    .tab-buttons {
        gap: 4px;
        max-width: calc(100% - 100px);
    }
    
    .tab-button {
        padding: 8px 10px;
        font-size: 12px;
        letter-spacing: -0.3px;
    }
    
    .terminal-status {
        font-size: 10px;
        gap: 4px;
        padding: 8px 10px;
    }
    
    .status-indicator {
        width: 6px;
        height: 6px;
    }
}

/* Iframe-friendly adjustments */
@media (max-height: 600px) {
    .modal-content {
        max-height: 85vh;
        padding: 20px;
    }

    .form-group {
        margin-bottom: 15px;
    }
}