:root, :host, [data-theme="light"] {
    --ios-bg: #F2F2F7;
    --ios-card: #FFFFFF;
    --ios-blue: #007AFF;
    --ios-green: #34C759;
    --ios-red: #FF3B30;
    --ios-gray: #8E8E93;
    --ios-gray-light: #E5E5EA;
    --ios-input-bg: #F2F2F7;
    --ios-separator: #C6C6C8;
    --text-primary: #000000;
    --text-secondary: #8E8E93;
    --text-inverse: #FFFFFF;
    --shadow-color: rgba(0, 0, 0, 0.04);
    --code-bg: #1C1C1E;
}

[data-theme="dark"] {
    --ios-bg: #000000;
    --ios-card: #1C1C1E;
    --ios-gray-light: #2C2C2E;
    --ios-input-bg: #2C2C2E;
    --ios-separator: #38383A;
    --text-primary: #FFFFFF;
    --text-secondary: #98989D;
    --text-inverse: #000000;
    --shadow-color: rgba(255, 255, 255, 0.05);
    --code-bg: #000000;
}

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

/* APP ROOT STYLES (Toggleable) */
/* Default state is defined in inline style via gulpfile (hidden) */
#vg-app-root {
    background-color: var(--ios-bg);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Visible State (Expanded from Bubble) */
#vg-app-root.visible {
    width: 100% !important;
    height: 100% !important;
    opacity: 1 !important;
}
#vg-app-root.visible .vg-bubble { 
   display: none !important; 
}

/* Main Layout */
.split-layout { display: flex; height: 100%; width: 100%; flex-direction: row; }
.left-panel { flex: 0 0 100%; height: 100%; overflow-y: auto; background: var(--ios-bg); border-right: 1px solid var(--ios-separator); padding: 15px; }
.right-panel { flex: 1; height: 100%; background: var(--ios-bg); display: flex; flex-direction: column; overflow: hidden; }

/* Header & Meta */
.header { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; }
.header-top-row { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.header-left-group { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.status { font-size: 14px; color: var(--ios-green); line-height: 1; flex-shrink: 0; }

.project-switcher { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.project-selector {
    padding: 5px 10px; background: var(--ios-input-bg); border: 1px solid var(--ios-separator);
    border-radius: 6px; font-size: 14px; font-weight: 700; color: var(--text-primary);
    cursor: pointer; outline: none; transition: all 0.2s; max-width: 100%; text-overflow: ellipsis;
}
.project-count { font-size: 10px; color: var(--text-secondary); background: var(--ios-gray-light); padding: 3px 7px; border-radius: 10px; font-weight: 600; white-space: nowrap; }

.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.theme-toggle, .stop-server-btn, .expand-btn {
    width: 28px; height: 28px; border-radius: 50%; border: none;
    background: var(--ios-card); cursor: pointer;
    box-shadow: 0 2px 5px var(--shadow-color);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-primary); transition: transform 0.2s;
}
.theme-toggle:hover, .stop-server-btn:hover, .expand-btn:hover { transform: scale(1.1); }
.stop-server-btn { background: var(--ios-red); color: white; }

.header-bottom-row { width: 100%; padding-left: 2px; }
.project-meta { font-size: 11px; color: var(--text-secondary); font-family: monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; width: 100%; line-height: 1.4; }

/* Cards & Components */
.system-prompt-card, .endpoint-card { background: var(--ios-card); border-radius: 10px; padding: 12px; margin-bottom: 12px; box-shadow: 0 1px 3px var(--shadow-color); }
.system-prompt-header, .endpoint-header { display: flex; justify-content: space-between; cursor: pointer; }
.system-prompt-content { max-height: 0; overflow: hidden; transition: max-height 0.3s; }
.system-prompt-content.open { max-height: 500px; margin-top: 10px; }
.prompt-text { background: var(--ios-input-bg); padding: 8px; border-radius: 6px; font-size: 11px; font-family: monospace; max-height: 150px; overflow-y: auto; color: var(--text-primary); }

.form-group { margin-bottom: 10px; }
.form-group input, .form-group textarea { width: 100%; padding: 6px 10px; background: var(--ios-input-bg); border: none; border-radius: 6px; font-family: monospace; font-size: 12px; color: var(--text-primary); }
.btn-group { display: flex; gap: 8px; margin-top: 10px; }
.btn { flex: 1; padding: 6px 12px; border: none; border-radius: 6px; background: var(--ios-blue); color: white; font-size: 12px; cursor: pointer; }
.btn-icon-head { width: 24px; height: 24px; background: rgba(0, 0, 0, 0.05); border: none; border-radius: 6px; cursor: pointer; color: var(--text-primary); }
.response { margin-top: 10px; padding: 8px; background: var(--code-bg); color: white; border-radius: 6px; font-size: 11px; display: none; max-height: 200px; overflow-y: auto; }
.response.show { display: block; }

/* Toast */
.toast { position: fixed; bottom: 20px; left: 20px; transform: translateY(100px); transition: transform 0.3s; background: var(--ios-green); color: white; padding: 8px 16px; border-radius: 8px; font-size: 13px; z-index: 99999; }
.toast.show { transform: translateY(0); }
.toast.error { background: var(--ios-red); }

/* Saved Commands */
.saved-commands-panel { background: var(--ios-card); margin-bottom: 12px; }
.saved-commands-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.saved-commands-title { font-weight: 600; font-size: 13px; color: var(--text-primary); display: flex; gap: 8px; align-items: center; }
.commands-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; max-height: 300px; overflow-y: auto; }
.command-card { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; background: var(--ios-input-bg); border-radius: 6px; cursor: pointer; transition: all 0.2s; height: 42px; }
.command-card:hover { background: var(--ios-gray-light); }
.command-name { font-weight: 600; font-size: 12px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.command-text { font-family: monospace; font-size: 10px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.command-action-btn { background: transparent; border: none; cursor: pointer; color: var(--text-secondary); }

/* Modal */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); z-index: 10000; align-items: center; justify-content: center; }
.modal-content { background: var(--ios-card); border-radius: 12px; padding: 20px; width: 90%; max-width: 400px; color: var(--text-primary); }

#resize-handler {
    width: 8px;
    cursor: ew-resize;
    background: transparent;
    transition: background 0.2s ease;
}
#resize-handler:hover {
    background: rgba(102, 126, 234, 0.5);
}